当前位置: 首页>>代码示例>>Python>>正文


Python Graph.yCoord方法代码示例

本文整理汇总了Python中Graph.yCoord方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.yCoord方法的具体用法?Python Graph.yCoord怎么用?Python Graph.yCoord使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Graph的用法示例。


在下文中一共展示了Graph.yCoord方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Create

# 需要导入模块: import Graph [as 别名]
# 或者: from Graph import yCoord [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="")
开发者ID:ProgVal,项目名称:Gato-mirror,代码行数:40,代码来源:GraphCreator.py


注:本文中的Graph.yCoord方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。