Created
May 1, 2018 12:43
-
-
Save diije/193ec57d7e1347db91c52699c4f08ccd to your computer and use it in GitHub Desktop.
Converting from Networkx to Python-Igraph
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import networkx as nx | |
Gnx = nx.path_graph(4) # Create a random NX graph | |
nx.write_graphml(G,'graph.graphml') # Export NX graph to file | |
import igraph as ig | |
Gix = ig.read('graph.graphml',format="graphml") # Create new IG graph from file |
I applied your solution, and it looks like igraph currently do not support GraphML. Please check the below error.
---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)
<ipython-input-2-0d19e71fcb45> in <module>
----> 1 G = ig.read('thesaurus_com_syn_graph_maincomponent.graphml',format="graphml")
~\anaconda3\lib\site-packages\igraph\__init__.py in read(filename, *args, **kwds)
4771 @param filename: the name of the file to be loaded
4772 """
-> 4773 return Graph.Read(filename, *args, **kwds)
4774 load=read
4775
~\anaconda3\lib\site-packages\igraph\__init__.py in Read(klass, f, format, *args, **kwds)
2621 raise IOError("no reader method for file format: %s" % str(format))
2622 reader = getattr(klass, reader)
-> 2623 return reader(f, *args, **kwds)
2624 Load = Read
2625
NotImplementedError: Error at c:\users\vssadministrator\appdata\local\temp\pip-req-build-f_aw61lh\vendor\build\igraph\igraph-0.8.3-msvc\src\foreign-graphml.c:1446: GraphML support is disabled, Unimplemented function call
@thepunitsingh igraph lib might have evolved a bit since I published this gist. Check the docs: https://igraph.org/python/doc/igraph.GraphBase-class.html#Read_GraphML
Great! Your solution help me! Thank!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@parth-verma thank you for such a nice comment!
In my experience of working with the kind of volume you mention, that's quicker and requires less RAM than other methods I tried. But please feel free to share a better way to do this.