graph-tool:如何找到适合某个属性值的顶点?

时间:2018-06-15 16:05:42

标签: python graph graph-tool

我有一个类Node,我使用graph-tool将其设置为图形的属性。

from graph_tool.all import *

class Node(object):
    def __init__(self, name, age):
        self.symbol = name
        self.named_entity = age


#create your graph object
g = Graph()

#add the property to vertex object
vprop = g.new_vertex_property("string") 

#add vertex 
v1 = g.add_vertex() #here you create a vertex
v2 = g.add_vertex() #here you create a vertex

#set the value to the vertex property
vx1 = Node("John", 15)
vx2 = Node("Sarah", 22)

v_prop[v1] = vx1
v_prop[v2] = vx2

#assign properties as a dic value
g.vertex_properties["node"]=vprop 

#add edge
g.add_edge(vertex_1,vertex_2) #add an edge 

# This does not work
find_match(g, "red")

如何在每个节点的名称年龄字段中找到匹配相等的顶点? find_match()函数似乎只适用于PropertyMap的本机类型。

0 个答案:

没有答案