[Networkit] Loading a GEXF file in Networkit

Pramod Herath pherath at g.clemson.edu
Mon Nov 28 14:19:54 CET 2016


Hello Networkit community!

I am an electrical engineering student who needs to create a huge graph and
do some processing on it. So please bear with my newbie questions.

As a test I've written a small code to read  a GEXF file that contains a
weighted, directed graph and it's not working. The following is the code:


from networkit import *

G = graphio.GEXFReader().read("result3.gexf")
pf = profiling.Profile.create(G,  preset="minimal")
pf.output("HTML",".")

I get the following error when I run it.

[jaya at node1904 networkit]$ ipython profiling.py
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
/scratch1/rjayawa/networkit/profiling.py in <module>()
      1 from networkit import *
      2
----> 3 G = graphio.GEXFReader().read("result3.gexf")
      4 pf = profiling.Profile.create(G,  preset="minimal")
      5 pf.output("HTML",".")

/home/jaya/.local/lib/python3.4/site-packages/networkit/GEXFIO.py in
read(self, fpath)
    101                         edge = self.q.get()
    102                         (u, v, w) = (edge[0], edge[1],
float(edge[2]))
--> 103                         self.g.addEdge(self.mapping[u],
self.mapping[v], w)
    104
    105                 #5.2 Sorting the eventStream by time and adding
timeStep between events that happen in different times

KeyError: '3'



and result3.gexf is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<gexf xmlns="http://www.gexf.net/1.2draft" version="1.2">
<graph mode="static" defaultedgetype="directed">
<nodes>
<node id="6" label="6" />
<node id="7" label="7" />
<node id="2" label="2" />
<node id="4" label="4" />
<node id="5" label="5" />
<node id="1" label="1" />
<node id="0" label="0" />
<node id="10" label="10" />
<node id="8" label="8" />
</nodes>
<edges>
<edge id="0" source="6" target="3" weight="3" />
<edge id="1" source="7" target="13" weight="1" />
<edge id="2" source="7" target="12" weight="1" />
<edge id="3" source="2" target="5" weight="1" />
<edge id="4" source="4" target="8" weight="1" />
<edge id="5" source="5" target="0" weight="1" />
<edge id="6" source="1" target="3" weight="1" />
<edge id="7" source="0" target="7" weight="1" />
<edge id="8" source="10" target="2" weight="2" />
<edge id="9" source="0" target="5" weight="1" />
<edge id="10" source="4" target="11" weight="1" />
<edge id="11" source="8" target="8" weight="1" />
</edges>
</graph>
</gexf>

Please help.

Thank you very much.

Regards,
Pramod
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ira.uni-karlsruhe.de/pipermail/networkit/attachments/20161128/fbe43e89/attachment.html>


More information about the NetworKit mailing list