__init__.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:gnpy 作者: Telecominfraproject 项目源码 文件源码
def network_from_json(json_data):
    # NOTE|dutc: we could use the following, but it would tie our data format
    #            too closely to the graph library
    # from networkx import node_link_graph
    g = DiGraph()

    nodes = {}
    for el in json_data['elements']:
        el = getattr(elements, el['type'])(el['id'], **el['metadata'])
        g.add_node(el)
        nodes[el.id] = el

    for cx in json_data['connections']:
        from_node, to_node = nodes[cx['from_node']], nodes[cx['to_node']]
        g.add_edge(from_node, to_node)

    return g
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号