【问题标题】:How to find neighbor vertex with a property value in graph_tool如何在 graph_tool 中找到具有属性值的相邻顶点
【发布时间】:2019-05-19 23:59:42
【问题描述】:

我有一个带有一些顶点和边的图。我想查找给定顶点的哪些邻居与属性值匹配。我可以用find_vertex(g, prop, match) 做到这一点,但这会在所有图表中搜索。相反,我有neighbors = g.vertex(N).out_neighbors(),我想获取具有属性值的顶点,例如find_vertex(neighbors, prop, match)。我该怎么做?

【问题讨论】:

    标签: python graph-tool


    【解决方案1】:

    为什么不

    neighbors = g.vertex(N).out_neighbors()
    [neigh for neigh in neighbors if g.vp[prop][neigh] == match]
    

    【讨论】:

    • 我正在寻找一种非常快速的方法
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-07-30
    • 1970-01-01
    • 1970-01-01
    • 2015-05-03
    • 1970-01-01
    • 2019-05-29
    • 2022-01-22
    相关资源
    最近更新 更多