finesse.utilities.graph.copy_graph

finesse.utilities.graph.copy_graph(G)[source]

A trick I often see in networkx’s codebase to copy a graph. type(G) returns the class of G (e.g. nx.DiGraph) which can accept a graph to make a copy of. Useful for writing ‘pure’ functions on graphs.