本文整理汇总了Python中graph_tool.Graph.new_graph_property方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.new_graph_property方法的具体用法?Python Graph.new_graph_property怎么用?Python Graph.new_graph_property使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类graph_tool.Graph
的用法示例。
在下文中一共展示了Graph.new_graph_property方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: user_network
# 需要导入模块: from graph_tool import Graph [as 别名]
# 或者: from graph_tool.Graph import new_graph_property [as 别名]
def user_network(storage, track, session):
g = Graph()
users = defaultdict(g.add_vertex)
g.graph_properties["track"] = g.new_graph_property("string", track)
g.graph_properties["session"] = g.new_graph_property("string", session)
g.edge_properties["created_at"] = g.new_edge_property("int64_t")
for tweet in storage:
tweeter_id = tweet["user__id_str"]
origin_id = tweet["retweeted_status__user__id_str"]
created_at = arrow.get(tweet["created_at"], DATE_FORMAT).timestamp
if origin_id:
edge = g.add_edge(users[tweeter_id], users[origin_id])
g.edge_properties["created_at"][edge] = created_at
return g
示例2:
# 需要导入模块: from graph_tool import Graph [as 别名]
# 或者: from graph_tool.Graph import new_graph_property [as 别名]
e1615 = child_graph.add_edge(child_graph.vertex_index[16], child_graph.vertex_index[15])
e2015 = child_graph.add_edge(child_graph.vertex_index[20], child_graph.vertex_index[15])
e2115 = child_graph.add_edge(child_graph.vertex_index[21], child_graph.vertex_index[15])
e1716 = child_graph.add_edge(child_graph.vertex_index[17], child_graph.vertex_index[16])
e2116 = child_graph.add_edge(child_graph.vertex_index[21], child_graph.vertex_index[16])
e2216 = child_graph.add_edge(child_graph.vertex_index[22], child_graph.vertex_index[16])
e2317 = child_graph.add_edge(child_graph.vertex_index[23], child_graph.vertex_index[17])
e1918 = child_graph.add_edge(child_graph.vertex_index[19], child_graph.vertex_index[18])
e2019 = child_graph.add_edge(child_graph.vertex_index[20], child_graph.vertex_index[19])
e2120 = child_graph.add_edge(child_graph.vertex_index[21], child_graph.vertex_index[20])
e2221 = child_graph.add_edge(child_graph.vertex_index[22], child_graph.vertex_index[21])
e2322 = child_graph.add_edge(child_graph.vertex_index[23], child_graph.vertex_index[22])
## Property definition
graph_name = child_graph.new_graph_property("string")
layer_capacities = child_graph.new_edge_property("int")
layer_res_capacity = child_graph.new_edge_property("int")
layer_flow = child_graph.new_edge_property("int")
alternate_path = child_graph.new_edge_property("int")
flag_path = child_graph.new_edge_property("int")
## Property Assignment
child_graph.gp.layer_name = graph_name
child_graph.ep.edge_capacity = layer_capacities
child_graph.ep.residual_capacity = layer_res_capacity
child_graph.ep.edge_flow = layer_flow
child_graph.ep.shared_path = alternate_path
child_graph.ep.path_flag = flag_path
## Setting the name of the graph