cytoscape_graph(data, attrs=None, name='name', ident='id')
A dictionary of data conforming to cytoscape JSON format.
A dictionary containing the keys 'name' and 'ident' which are mapped to the 'name' and 'id' node elements in cyjs format. All other keys are ignored. Default is :None:None:`None`
which results in the default mapping dict(name="name", ident="id")
.
The :None:None:`attrs`
keyword argument will be replaced with :None:None:`name`
and :None:None:`ident`
in networkx 3.0
A string which is mapped to the 'name' node element in cyjs format. Must not have the same value as :None:None:`ident`
.
A string which is mapped to the 'id' node element in cyjs format. Must not have the same value as :None:None:`name`
.
If the :None:None:`name`
and :None:None:`ident`
attributes are identical.
The graph
can be an instance of Graph
, DiGraph
, MultiGraph
, or MultiDiGraph
depending on the input data.
Create a NetworkX graph from a dictionary in cytoscape JSON format.
cytoscape_data
convert a NetworkX graph to a dict in cyjs format
>>> data_dict = {
... 'data': [],
... 'directed': False,
... 'multigraph': False,
... 'elements': {'nodes': [{'data': {'id': '0', 'value': 0, 'name': '0'}},
... {'data': {'id': '1', 'value': 1, 'name': '1'}}],
... 'edges': [{'data': {'source': 0, 'target': 1}}]}
... }
... G = nx.cytoscape_graph(data_dict)
... G.name ''
>>> G.nodes() NodeView((0, 1))
>>> G.nodes(data=True)[0] {'id': '0', 'value': 0, 'name': '0'}
>>> G.edges(data=True) EdgeDataView([(0, 1, {'source': 0, 'target': 1})])See :
The following pages refer to to this document either explicitly or contain code examples using this.
networkx.readwrite.json_graph.cytoscape.cytoscape_graph
networkx.readwrite.json_graph.cytoscape.cytoscape_data
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them