Note

This documents the development version of NetworkX. Documentation for the current release can be found here.

networkx.readwrite.json_graph.adjacency_graph

adjacency_graph(data, directed=False, multigraph=True, attrs={'id': 'id', 'key': 'key'})[source]

Returns graph from adjacency data format.

Parameters
datadict

Adjacency list formatted graph data

directedbool

If True, and direction not specified in data, return a directed graph.

multigraphbool

If True, and multigraph not specified in data, return a multigraph.

attrsdict

A dictionary that contains two keys ‘id’ and ‘key’. The corresponding values provide the attribute names for storing NetworkX-internal graph data. The values should be unique. Default value: dict(id='id', key='key').

Returns
GNetworkX graph

A NetworkX graph object

Notes

The default value of attrs will be changed in a future release of NetworkX.

Examples

>>> from networkx.readwrite import json_graph
>>> G = nx.Graph([(1, 2)])
>>> data = json_graph.adjacency_data(G)
>>> H = json_graph.adjacency_graph(data)