本文整理汇总了Python中AutoNetkit.load_zoo方法的典型用法代码示例。如果您正苦于以下问题:Python AutoNetkit.load_zoo方法的具体用法?Python AutoNetkit.load_zoo怎么用?Python AutoNetkit.load_zoo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AutoNetkit
的用法示例。
在下文中一共展示了AutoNetkit.load_zoo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load
# 需要导入模块: import AutoNetkit [as 别名]
# 或者: from AutoNetkit import load_zoo [as 别名]
def load(self, filename):
"""Loads the network description from a graph file.
Note this is done automatically if a filename is given to
the Internet constructor.
Args:
filename: The file to load from
Returns:
None
Example usage:
>>> inet = ank.internet.Internet()
>>> inet.load("simple")
>>> sorted(inet.network.graph.nodes())
[RouterB.AS1, RouterA.AS1, RouterD.AS2, RouterC.AS1, RouterA.AS2, RouterA.AS3, RouterB.AS2, RouterC.AS2]
>>> inet = ank.internet.Internet()
>>> inet.load("singleas")
>>> sorted(inet.network.graph.nodes())
[1a.AS1, 1b.AS1, 1d.AS1, 1c.AS1]
>>> inet = ank.internet.Internet()
>>> inet.load("multias")
>>> sorted(inet.network.graph.nodes())
[1b.AS1, 1a.AS1, 2d.AS2, 1c.AS1, 2a.AS2, 3a.AS3, 2b.AS2, 2c.AS2]
"""
LOG.info("Loading")
ext = os.path.splitext(filename)[1]
if ext == "":
#TODO: use try/except block here
self.network.graph = ank.load_example(filename)
#TODO: allow url to be entered, eg from zoo, if so then download the file and proceed on as normal
elif ext == ".gml":
# GML file from Topology Zoo
ank.load_zoo(self.network, filename)
elif ext == ".graphml":
self.network.graph = ank.load_graphml(filename)
elif ext == ".pickle":
LOG.warn("AutoNetkit no longer supports pickle file format, please use GraphML")
elif ext == ".yaml":
# Legacy ANK file format
LOG.warn("AutoNetkit no longer supports YAML file format, please use GraphML")
else:
LOG.warn("AutoNetkit does not support file format %s" % ext)
#TODO: check that loaded network has at least one node, if not throw exception
self.network.instantiate_nodes()