networkx 2.8.2 Pypi GitHub Homepage
Other Docs
ParametersRaisesReturnsBackRef
cytoscape_data(G, attrs=None, name='name', ident='id')

Parameters

G : NetworkX Graph

The graph to convert to cytoscape format

attrs : dict or None (default=None)

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") .

deprecated

The :None:None:`attrs` keyword argument will be replaced with :None:None:`name` and :None:None:`ident` in networkx 3.0

name : string

A string which is mapped to the 'name' node element in cyjs format. Must not have the same value as :None:None:`ident`.

ident : string

A string which is mapped to the 'id' node element in cyjs format. Must not have the same value as :None:None:`name`.

Raises

NetworkXError

If the values for :None:None:`name` and :None:None:`ident` are identical.

Returns

data: dict

A dictionary with cyjs formatted data.

Returns data in Cytoscape JSON format (cyjs).

See Also

cytoscape_graph

convert a dictionary in cyjs format to a graph

Examples

>>> G = nx.path_graph(2)
... nx.cytoscape_data(G) # doctest: +SKIP {'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}}]}}
See :

Back References

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

Local connectivity graph

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


GitHub : /networkx/readwrite/json_graph/cytoscape.py#6
type: <class 'function'>
Commit: