本文整理汇总了Python中graph_tool.Graph.vertex_properties["pos"]方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.vertex_properties["pos"]方法的具体用法?Python Graph.vertex_properties["pos"]怎么用?Python Graph.vertex_properties["pos"]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类graph_tool.Graph
的用法示例。
在下文中一共展示了Graph.vertex_properties["pos"]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_graph_from_string
# 需要导入模块: from graph_tool import Graph [as 别名]
# 或者: from graph_tool.Graph import vertex_properties["pos"] [as 别名]
def parse_graph_from_string(self, graphML_string):
dom = minidom.parseString(graphML_string)
root = dom.getElementsByTagName("graphml")[0]
graph = root.getElementsByTagName("graph")[0]
name = graph.getAttribute('id')
g = Graph(directed=False)
vpos=g.new_vertex_property("vector<double>")
for node in graph.getElementsByTagName("node"):
id=node.getAttribute('id')
n = g.add_vertex()
g.vertex_index[id]
#right now only the positions are available
for attr in node.getElementsByTagName("data"):
if attr.firstChild:
key=attr.getAttribute("key")
#n[key] = attr.firstChild.data
if(key=="x"):
x=attr.firstChild.data
elif(key=="y"):
y=attr.firstChild.data
vpos[id]=(x,y)
g.vertex_properties["pos"]=vpos
#have to workaround the directed graph written by the server
for edge in graph.getElementsByTagName("edge"):
source = edge.getAttribute('source')
dest = edge.getAttribute('target')
edge=g.edge(dest,source)
if(edge==None):
e = g.add_edge(source, dest)
return g