本文整理汇总了Python中Graph.xCoord[v]方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.xCoord[v]方法的具体用法?Python Graph.xCoord[v]怎么用?Python Graph.xCoord[v]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graph
的用法示例。
在下文中一共展示了Graph.xCoord[v]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Create
# 需要导入模块: import Graph [as 别名]
# 或者: from Graph import xCoord[v] [as 别名]
def Create(self, theGraphEditor):
theGraphEditor.config(cursor="watch")
dial = GridDialog(theGraphEditor, 1, "Create Grid Graph")
if dial.result is None:
theGraphEditor.config(cursor="")
return
maxI = dial.result[0]
maxJ = dial.result[1]
deltax = dial.result[2]
deltay = dial.result[2]
G=Graph()
G.directed=0
G.xCoord={}
G.yCoord={}
nodes = {}
count = 1
for i in xrange(maxI):
for j in xrange(maxJ):
v = G.AddVertex()
nodes[(i,j)] = v
G.xCoord[v] = j * deltax + deltax
G.yCoord[v] = i * deltay + deltay
count += 1
for i in xrange(maxI-1):
for j in xrange(maxJ-1):
G.AddEdge(nodes[(i,j)], nodes[(i+1,j)], initialize_weight=False)
G.AddEdge(nodes[(i,j)], nodes[(i,j+1)], initialize_weight=False)
G.AddEdge(nodes[(i,maxJ-1)], nodes[(i+1,maxJ-1)], initialize_weight=False)
for j in xrange(maxJ-1):
G.AddEdge(nodes[(maxI-1,j)], nodes[(maxI-1,j+1)], initialize_weight=False)
DrawNewGraph(theGraphEditor,G,G.directed)
theGraphEditor.config(cursor="")