本文整理匯總了Python中router.Router.get_shortest_path方法的典型用法代碼示例。如果您正苦於以下問題:Python Router.get_shortest_path方法的具體用法?Python Router.get_shortest_path怎麽用?Python Router.get_shortest_path使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類router.Router
的用法示例。
在下文中一共展示了Router.get_shortest_path方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_router
# 需要導入模塊: from router import Router [as 別名]
# 或者: from router.Router import get_shortest_path [as 別名]
def test_router(net, land):
from router import Router
net.init_flows()
print 'edges'
pprint([(edge, str(edge)) for edge in net.edges])
path = Router.find_shortest_path(net, 0, net.nodes[1], net.nodes[6])
print 'path 1 - 6'
pprint(path)
path = Router.find_shortest_path(net, 0, net.nodes[6], net.nodes[1])
print 'path 6 - 1'
pprint(path)
paths = Router.find_shortest_path(net, 0, net.nodes[1])
print 'paths 1 - *'
pprint(paths)
paths = Router.find_shortest_path(net, 0, net.nodes[100])
print 'paths 100 - *'
pprint(paths)
router = Router(net, land)
print 'building shortest paths...'
router.build_shortest_paths()
# logger.debug(pformat(dict(router.paths)))
path = router.get_shortest_path(0, 100, 100)
print 'path 100 - 100'
pprint(path)
path = router.get_shortest_path(0, 100, 200)
print 'path 100 - 200'
pprint(path)
path = router.get_shortest_path(0, 100, 600)
print 'path 100 - 600'
pprint(path)
return router