简体   繁体   中英

Is it possible to create a property graph in NetworKit?

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!

Now, the latest version provide an API called "attachNodeAttribute" to create attribute for each node in a graph.

https:/.networkit.github.io/dev-docs/python_api.networkit.html?highlight=attachnodeattribute.networkit.Graph.attachNodeAttribute

NetworKit does not store internally additional node/edge attributes. However, assuming that you have a graph G , you can store properties externally (eg, 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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM