0

Is there a simple way to create a GML file out of edgelists (comma separated) using Python? This is the opposite situation of this question

Community
  • 1
  • 1
kevin
  • 1,914
  • 4
  • 25
  • 30

2 Answers2

0

I've found a question similar to mine and a solution from here. I just adapted the solution for my dataset. Hope this is helpful for others.

G = nx.read_edgelist('edgelistFile.csv', delimiter=',', nodetype=str, encoding="utf-8")
Community
  • 1
  • 1
kevin
  • 1,914
  • 4
  • 25
  • 30
0

Suppose you have an edge list file (.edges) and want to convert it a gml file, do this. The gml file will get created in your present working directory.

import networkx as nx
G= nx.read_edgelist('414.edges') # load edgelist file
nx.write_gml(G, "414.gml") # create gml file
Lin
  • 11
  • 3