

def node_link_graph(data, directed=False, multigraph=True, attrs=None):
    "Return graph from node-link data format.\n\n    Parameters\n    ----------\n    data : dict\n        node-link formatted graph data\n\n    directed : bool\n        If True, and direction not specified in data, return a directed graph.\n\n    multigraph : bool\n        If True, and multigraph not specified in data, return a multigraph.\n\n    attrs : dict\n        A dictionary that contains five keys 'source', 'target', 'name',\n        'key' and 'link'.  The corresponding values provide the attribute\n        names for storing NetworkX-internal graph data.  Default value:\n\n            dict(source='source', target='target', name='name',\n                key='key', link='links')\n\n    Returns\n    -------\n    G : NetworkX graph\n        A NetworkX graph object\n\n    Examples\n    --------\n    >>> from networkx.readwrite import json_graph\n    >>> G = nx.Graph([('A', 'B')])\n    >>> data = json_graph.node_link_data(G)\n    >>> H = json_graph.node_link_graph(data)\n\n    Notes\n    -----\n    Attribute 'key' is only used for multigraphs.\n\n    See Also\n    --------\n    node_link_data, adjacency_data, tree_data\n    "
    if (attrs is None):
        attrs = _attrs
    else:
        attrs.update({k: v for (k, v) in _attrs.iteritems() if (k not in attrs)})
    multigraph = data.get('multigraph', multigraph)
    directed = data.get('directed', directed)
    if multigraph:
        graph = nx.MultiGraph()
    else:
        graph = nx.Graph()
    if directed:
        graph = graph.to_directed()
    name = attrs['name']
    source = attrs['source']
    target = attrs['target']
    links = attrs['link']
    key = (None if (not multigraph) else attrs['key'])
    mapping = []
    graph.graph = data.get('graph', {
        
    })
    c = count()
    for d in data['nodes']:
        node = to_tuple(d.get(name, next(c)))
        mapping.append(node)
        nodedata = dict(((make_str(k), v) for (k, v) in d.items() if (k != name)))
        graph.add_node(node, **nodedata)
    for d in data[links]:
        src = d[source]
        tgt = d[target]
        if (not multigraph):
            edgedata = dict(((make_str(k), v) for (k, v) in d.items() if ((k != source) and (k != target))))
            graph.add_edge(mapping[src], mapping[tgt], **edgedata)
        else:
            ky = d.get(key, None)
            edgedata = dict(((make_str(k), v) for (k, v) in d.items() if ((k != source) and (k != target) and (k != key))))
            graph.add_edge(mapping[src], mapping[tgt], ky, **edgedata)
    return graph

dataset/ETHPy150Open networkx/networkx/networkx/readwrite/json_graph/node_link.py node_link_graph/original