user3698011
user3698011

Reputation: 167

How to convert file from gml to edgelist in python?

Is there any example in python, how to convert file from *.gml to *.edgelist? Thank you

Upvotes: 2

Views: 2159

Answers (1)

CurtLH
CurtLH

Reputation: 2417

In [1]:  import networkx as nx

In [2]:  g = nx.read_gml('gmlFile.gml')

In [3]:  nx.write_edgelist(g, 'edgelistFile.csv', delimiter=',')

Documentation

read_gml(path, encoding='UTF-8', relabel=False)

write_edgelist(G, path, comments='#', delimiter=' ', data=True, encoding='utf-8')[source]

Upvotes: 5

Related Questions