In igraph I found two different methods for converting graph to undirected graph:
The first is to_undirected which simply 'Converts a directed graph to undirected.' and the second is as_undirected which invokes to_undirected on the copy.
In NetworkX I found only single method to_undirected which simply create undirected deep copy of the graph. The problem is that I really can't found method similar to the first one in igraph. Is there any solution to transform graph without creating copy using NetworkX?
As you state,
networkx.to_undirectedcreates a deep copy of the graph. This means that it copies the edge, node, and graph attribute dictionaries. To create an undirected shallow copy of a digraphg, one can write:This is still a copy, but a shallow one in which the attribute dictionaries are not deep copied.
It does not appear that a method exists to convert a
DiGraphto aGraphin-place. Doing as much would mean changing the type of the object -- it's likely cleaner to simply do a shallow copy, and not that much more expensive.