Convert python-igraph graph to networkx
You can initiate a networkx graph with edges:
Graph([(1,2), (3,4)])
See the documentation.
EDIT:
This is how to use it (Thank you nimafl for the code):
graph
is the igraph
graph and we create G
which is a networkx
graph.
import networkx
A = graph.get_edgelist()
G = networkx.DiGraph(A) # In case your graph is directed
G = networkx.Graph(A) # In case you graph is undirected
As I try to store names of nodes/edges on both igraph or nx, this is my one-liner version which also transfers nodes names while transferring from igraph object, g
, to nx, G, the result:
G = nx.from_edgelist([(names[x[0]], names[x[1]])
for names in [g.vs['name']] # simply a let
for x in g.get_edgelist()], nx.DiGraph())
Also if you need the reverse way, have a look at this answer.