o
    ˷e
                     @   sP   d Z ddlZddlZddlZddlmZ ddgZd	ddZedd
ddZ	dS )a  
Read and write NetworkX graphs as JavaScript InfoVis Toolkit (JIT) format JSON.

See the `JIT documentation`_ for more examples.

Format
------
var json = [
  {
    "id": "aUniqueIdentifier",
    "name": "usually a nodes name",
    "data": {
      "some key": "some value",
      "some other key": "some other value"
     },
    "adjacencies": [
    {
      nodeTo:"aNodeId",
      data: {} //put whatever you want here
    },
    'other adjacencies go here...'
  },

  'other nodes go here...'
];
.. _JIT documentation: http://thejit.org
    N)not_implemented_for	jit_graphjit_datac                 C   s   t dt |du rt }n|}|  t| trt	| } | D ]-}|j
|d fi |d  |ddurN|d D ]}|j|d |d fi |d  q;q!|S )aT  Read a graph from JIT JSON.

    Parameters
    ----------
    data : JSON Graph Object

    create_using : Networkx Graph, optional (default: Graph())
        Return graph of this type. The provided instance will be cleared.

    Returns
    -------
    G : NetworkX Graph built from create_using if provided.

    .. deprecated:: 2.6
    z<jit_graph is deprecated and will be removed in NetworkX 3.0.NiddataadjacenciesnodeTo)warningswarnDeprecationWarningnxGraphclear
isinstancestrjsonloadsadd_nodegetadd_edge)r   create_usingGnodeadj r   X/var/www/ideatree/venv/lib/python3.10/site-packages/networkx/readwrite/json_graph/jit.pyr   &   s"   


"
multigraphc                 C   s   t dt g }|  D ]6}||d}| j| |d< | | r=g |d< | | D ]}d|i}| j||f |d< |d | q&|| qtj|||dS )a  Returns data in JIT JSON format.

    Parameters
    ----------
    G : NetworkX Graph

    indent: optional, default=None
        If indent is a non-negative integer, then JSON array elements and
        object members will be pretty-printed with that indent level.
        An indent level of 0, or negative, will only insert newlines.
        None (the default) selects the most compact representation.

    default: optional, default=None
         It will pass the value to the json.dumps function in order to
         be able to serialize custom objects used as nodes.

    Returns
    -------
    data: JIT JSON string

    .. deprecated:: 2.6
    z;jit_data is deprecated and will be removed in NetworkX 3.0.)r   namer   r   r   )indentdefault)r	   r
   r   nodesedgesappendr   dumps)r   r   r   
json_graphr   	json_node	neighbour	adjacencyr   r   r   r   L   s    
)N)NN)
__doc__r   r	   networkxr   networkx.utils.decoratorsr   __all__r   r   r   r   r   r   <module>   s    
&