本文整理汇总了Python中graph_tool.Graph.edge_properties["weights"]方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.edge_properties["weights"]方法的具体用法?Python Graph.edge_properties["weights"]怎么用?Python Graph.edge_properties["weights"]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类graph_tool.Graph
的用法示例。
在下文中一共展示了Graph.edge_properties["weights"]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_graph
# 需要导入模块: from graph_tool import Graph [as 别名]
# 或者: from graph_tool.Graph import edge_properties["weights"] [as 别名]
def load_graph(infile):
inmatrix = np.loadtxt(infile, dtype=np.dtype('uint32'), delimiter=" ")
numv = np.amax(inmatrix[:,0:2])
#print numv, inmatrix[:,0:2]
g = Graph(directed=False)
edge_weights = g.new_edge_property("double")
g.edge_properties["weights"] = edge_weights
vlist = list(g.add_vertex(numv))
for i in inmatrix:
edge = g.add_edge(vlist[i[0]-1], vlist[i[1]-1]) # need to convert from 1-based index in file to 0-based
edge_weights[edge] = i[2]
remove_parallel_edges(g)
return g