
    h                     P    S SK rSS/rSS jr\R                  " SSS9SS j5       rg)	    Ncytoscape_datacytoscape_graphc                 &   X:X  a  [         R                  " S5      eS[        U R                  R	                  5       5      0nU R                  5       US'   U R                  5       US'   / / S.US'   US   S   nUS   S   nU R                  R	                  5        H  u  pgSUR                  5       0nUR                  U5      =(       d    [        U5      US   S	'   XhS   S
'   UR                  U5      =(       d    [        U5      US   S'   UR                  U5        M     U R                  5       (       ax  U R                  SS9 Hc  n	SU R                  U	S      U	S      U	S      R                  5       0nU	S   US   S'   U	S   US   S'   U	S   US   S'   UR                  U5        Me     U$ U R                  5        HR  n	SU R                  U	S      U	S      R                  5       0nU	S   US   S'   U	S   US   S'   UR                  U5        MT     U$ )a!  Returns data in Cytoscape JSON format (cyjs).

Parameters
----------
G : NetworkX Graph
    The graph to convert to cytoscape format
name : string
    A string which is mapped to the 'name' node element in cyjs format.
    Must not have the same value as `ident`.
ident : string
    A string which is mapped to the 'id' node element in cyjs format.
    Must not have the same value as `name`.

Returns
-------
data: dict
    A dictionary with cyjs formatted data.

Raises
------
NetworkXError
    If the values for `name` and `ident` are identical.

See Also
--------
cytoscape_graph: convert a dictionary in cyjs format to a graph

References
----------
.. [1] Cytoscape user's manual:
   http://manual.cytoscape.org/en/stable/index.html

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}}]}}
!name and ident must be different.datadirected
multigraph)nodesedgeselementsr
   r   idvaluenameT)keysr         sourcetargetkey)nxNetworkXErrorlistgraphitemsis_directedis_multigraphr
   copygetstrappendr   adj)
Gr   identjsondatar
   r   ijnes
             Y/var/www/html/env/lib/python3.13/site-packages/networkx/readwrite/json_graph/cytoscape.pyr   r      s
   X }BCCQWW]]_-.H==?HZ__.H\%'"5HZZ )EZ )EQVVX%%,0#a&&	$&	'EE$K13q6&	&Q   	d#AqtQqT*1Q405578A"#A$AfIh"#A$AfIh tAfIeLLO $ O AqtQqT*//12A"#A$AfIh"#A$AfIhLLO	 
 O    T)graphsreturns_graphc                    X:X  a  [         R                  " S5      eU R                  S5      nU R                  S5      nU(       a  [         R                  " 5       nO[         R                  " 5       nU(       a  UR                  5       n[        U R                  S5      5      Ul        U S   S    H  nUS   R                  5       nUS   S   nUS   R                  U5      (       a  US   R                  U5      Xq'   US   R                  U5      (       a  US   R                  U5      Xr'   UR                  U5        UR                  U   R                  U5        M     U S   S    H  nUS   R                  5       n	US   S	   n
US   S
   nU(       aG  US   R                  SS5      nUR                  XUS9  UR                  XU4   R                  U	5        Mt  UR                  X5        UR                  X4   R                  U	5        M     U$ )a  
Create a NetworkX graph from a dictionary in cytoscape JSON format.

Parameters
----------
data : dict
    A dictionary of data conforming to cytoscape JSON format.
name : string
    A string which is mapped to the 'name' node element in cyjs format.
    Must not have the same value as `ident`.
ident : string
    A string which is mapped to the 'id' node element in cyjs format.
    Must not have the same value as `name`.

Returns
-------
graph : a NetworkX graph instance
    The `graph` can be an instance of `Graph`, `DiGraph`, `MultiGraph`, or
    `MultiDiGraph` depending on the input data.

Raises
------
NetworkXError
    If the `name` and `ident` attributes are identical.

See Also
--------
cytoscape_data: convert a NetworkX graph to a dict in cyjs format

References
----------
.. [1] Cytoscape user's manual:
   http://manual.cytoscape.org/en/stable/index.html

Examples
--------
>>> 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})])
r   r	   r   r   r   r
   r   r   r   r   r   r   )r   )r   r   r   
MultiGraphGraphto_directeddictr   r   add_noder
   updateadd_edger   )r   r   r#   r	   r   r   d	node_datanode	edge_datasourtargr   s                r)   r   r   S   s   x }BCC,'Jxx
#H
!!#txx'(EK*g&fINN$	y!V9==immD1IOV9== y}}U3ItD  + ' *g&fINN$	y"y"F)--q)CNN43N/KKC(//	:NN4&KK
#**95 ' Lr*   )r   r   )networkxr   __all__r   _dispatchabler    r*   r)   <module>r?      s=    .
/JZ T2^ 3^r*   