本文整理匯總了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