【问题标题】:Is it possible to create a property graph in NetworKit?是否可以在 NetworKit 中创建属性图?
【发布时间】:2019-05-06 21:24:45
【问题描述】:

例如,我想为节点和边添加一些属性(例如,一些标签或任何其他附加信息)。

是否可以在 NetworKit 中做到这一点?

提前谢谢你!

【问题讨论】:

    标签: python property-graph networkit


    【解决方案1】:

    NetworKit 不会在内部存储额外的节点/边缘属性。但是,假设您有一个图形G,您可以在外部存储属性(例如,在列表或地图中),并使用节点/边 ID 来访问它们。在 NetworKit 中,节点 id 的索引总是从 0 到 G.upperNodeIdBound() - 1,而边缘 id 的索引总是从 0 到 G.upperEdgeIdBound() - 1

    要使用边缘 ID,您首先需要调用G.indexEdges(),因为默认情况下不会生成边缘 ID。然后,G.edgeId(u, v) 将节点 u 的边的 id 返回到节点 v

    您可以在documentation of the NetworKit Graph class 中找到更多相关信息。

    【讨论】:

    • 感谢您的回答!最初我打算使用 NetworKit 作为知识库的存储,但我想这不会有多大用处(例如在内存使用方面),因为我必须将一些附加信息存储为 python 对象。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-09
    • 2014-06-11
    • 2020-05-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多