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


Python Graph.edges方法代码示例

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


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

示例1: Edge

# 需要导入模块: import Graph [as 别名]
# 或者: from Graph import edges [as 别名]
e5 = Edge(v,q)

#Test some methods
#get_edge(e)
g.get_edge(v,w)

print "got e1"

g.get_edge(v,q)

print "\n"
print g
print "\n"

#remove_edge(e)
# g1.remove_edge(e1)
# g1.remove_edge(e2)
# g1.remove_edge(e3)

# print "The graph with removed edge\n"
# print g1


print "Print all the vertices in the graph"

print g.vertices()

print "Print all the edges in the graph"

print g.edges()
开发者ID:cmnzs,项目名称:think-complexity,代码行数:32,代码来源:tester.py

示例2: point

# 需要导入模块: import Graph [as 别名]
# 或者: from Graph import edges [as 别名]
from Graph import *
from Queue import *
from path_finder import *
from SquareGrid import *
from GridWithWeights import *

#section breadth_first_search start from some point(node)
example_graph = Graph()

example_graph.edges = {
    'A' : ['B'],
    'B' : ['A', 'C', 'D'],
    'C' : ['A'],
    'D' : ['E', 'A'],
    'E' : ['B']
}

print("breadth_first_search from one start point:")
breadth_first_search(example_graph, 'A')

#section breadth_first_search from start to goal
DIAGRAM1_WALLS = [from_id_width(id, width=30) for id in [21,22,51,52,81,82,93,94,111,112,123,124,133,134,141,142,153,154,163,164,171,172,173,174,175,183,184,193,194,201,202,203,204,205,213,214,223,224,243,244,253,254,273,274,283,284,303,304,313,314,333,334,343,344,373,374,403,404,433,434]]

g = SquareGrid(30, 15)
g.walls = DIAGRAM1_WALLS

start = (8, 7)
goal = (18, 8)
parents = breadth_first_search(g, start, goal)
print("bread_first_search from %r to %r" % (start, goal))
draw_grid(g, width=2, point_to=parents, start=start, goal=goal)
开发者ID:hsgui,项目名称:interest-only,代码行数:33,代码来源:test.py


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