[Networkit] adding weights to a new created graph

Michelangelo Puliga michelangelo.puliga at imtlucca.it
Thu Jun 12 10:39:47 CEST 2014

Dear NetworKit developers,
  I'm trying to use Networkit in the python realization to analyze a
network for community detection. Instead of reading the data from a
metis file I'm trying to create a graph (weidghted undirected)

Here an example in ipython3

In[1]: import NetworKit as nk

In [2]: G = nk.Graph()

In [3]: G.addNode()
Out[3]: 0

In [4]: G.addNode()
Out[4]: 1

In [5]: G.addNode()
Out[5]: 2

In [6]: G.addEdge(0,1,0.1)

In [7]: G.edges()
Out[7]: [(1, 0)]

In [8]: G.weight(0,1)
Out[8]: 1.0

In [9]: G.weight(1,0)
Out[9]: 1.0

the weight associated to the edge (0,1) is always 1. while I defined
in addEdge(0,1,0.1)  weight = 0.1

finally if I try to convert an weighted graph from NetworkX to
NetworKit I got the error that MarkAsWeighted function is not defined
(there is a todo in the source code )...

Any help/suggestion to load a weighted network programmatically from
the code (addnode, addedge ?)



More information about the NetworKit mailing list