本文整理汇总了Python中networkx.from_dict_of_dicts方法的典型用法代码示例。如果您正苦于以下问题:Python networkx.from_dict_of_dicts方法的具体用法?Python networkx.from_dict_of_dicts怎么用?Python networkx.from_dict_of_dicts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类networkx
的用法示例。
在下文中一共展示了networkx.from_dict_of_dicts方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: graph_from_dict
# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import from_dict_of_dicts [as 别名]
def graph_from_dict(graph_dict):
if 'graph_type' not in graph_dict:
raise ValueError('graph_dict must contain key "graph_type"')
# todo: use type() instead of this mess
if graph_dict['graph_type'] == 'MultiDiGraph':
return multi_digraph_from_dict(graph_dict['graph_dict'])
elif graph_dict['graph_type'] == 'MultiGraph':
return nx.from_dict_of_dicts(graph_dict['graph_dict'], multigraph_input=True)
elif graph_dict['graph_type'] == 'DiGraph':
return nx.from_dict_of_dicts(graph_dict['graph_dict'])
elif graph_dict['graph_type'] == 'Graph':
return nx.from_dict_of_dicts(graph_dict['graph_dict'])
elif graph_dict['graph_type'] == 'other':
return nx.from_dict_of_dicts(graph_dict['graph_dict'])
else:
raise ValueError("the value for 'graph_type' in graph_dict is not of the accepted values.")