2

For example, I would like to add some attributes to nodes and edges (say, some labels or any other additional info).

Is it possible to do that in NetworKit?

Thank you in advance!

elfinorr
  • 179
  • 3
  • 11

1 Answers1

1

NetworKit does not store internally additional node/edge attributes. However, assuming that you have a graph G, you can store properties externally (e.g., in a list or in a map), and use node/edge ids to access them. In NetworKit, node ids are always indexed from 0 to G.upperNodeIdBound() - 1, while edge ids are always indexed from 0 to G.upperEdgeIdBound() - 1.

To use edge ids, you first need to call G.indexEdges(), as edge ids are not generated by default. Then, G.edgeId(u, v) returns the id of the edge from node u to node v.

You can find more about this in the documentation of the NetworKit Graph class.

angriman
  • 345
  • 1
  • 10
  • 1
    Thank you for the answer! Originally I was planning to use NetworKit as a storage for a knowledge base, but I guess, that would not be much useful (in terms of memory usage, for example), because I have to store some additional info as a python objects.. – elfinorr May 13 '19 at 11:18