
    \Mhl                     h    d dl ZddgZdddZefdZ ej        dd	          d
defd            ZdS )    Nadjacency_dataadjacency_graphidkey)r   r   c           
         |                                  }|d         }|sdn|d         }||k    rt          j        d          i }|                                 |d<   ||d<   t	          | j                                                  |d<   g |d<   g |d	<   |                                 D ]\  }}|d                             i | j	        |         ||i           g }|rR|                                D ]<\  }	}
|
                                D ]"\  }}|                    i |||	||i           #=n5|                                D ] \  }	}|                    i |||	i           !|d	                             |           |S )
a&  Returns data in adjacency format that is suitable for JSON serialization
    and use in JavaScript documents.

    Parameters
    ----------
    G : NetworkX graph

    attrs : dict
        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:
        :samp:`dict(id='id', key='key')`.

        If some user-defined graph data use these attribute names as data keys,
        they may be silently dropped.

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

    Raises
    ------
    NetworkXError
        If values in attrs are not unique.

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

    To serialize with json

    >>> import json
    >>> s = json.dumps(data)

    Notes
    -----
    Graph, node, and link attributes will be written when using this format
    but attribute keys must be strings if you want to serialize the resulting
    data with JSON.

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

    See Also
    --------
    adjacency_graph, node_link_data, tree_data
    r   Nr   zAttribute names are not unique.directed
multigraphgraphnodes	adjacency)
is_multigraphnxNetworkXErroris_directedlistr
   itemsr   appendr   )Gattrsr	   id_r   datannbrdictadjnbrkeyskds                g/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/networkx/readwrite/json_graph/adjacency.pyr   r      s   d ""J
+C 
2$$eElC
czz@AAAD}}D#D))DMDMDkkmm 
& 
&
7W3
3C33444 	,$]]__ 8 8	T JJLL 8 8DAqJJ6!6S#sA66777788 "--// , ,Q

?a?c??++++[  %%%%K    T)graphsreturns_graphFc                    |                      d|          }|                      d|          }|rt          j                    }nt          j                    }|r|                                }|d         }|sdn|d         }t          |                      dg                     |_        g }| d         D ]u}|                                }	|	                    |          }
|	                    |
           |
                    |
           |j        |
                             |	           vt          | d                   D ]\  }}||         }|D ]}|                                }|                    |          }|s8|                    ||           ||         |                             |           e|                    |d          }|                    |||	           ||         |         |                             |           |S )
a&  Returns graph from adjacency data format.

    Parameters
    ----------
    data : dict
        Adjacency list formatted graph data

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

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

    attrs : dict
        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:
        :samp:`dict(id='id', key='key')`.

    Returns
    -------
    G : NetworkX graph
       A NetworkX graph object

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

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

    See Also
    --------
    adjacency_graph, node_link_data, tree_data
    r	   r   r   Nr   r
   r   r   )r   )getr   
MultiGraphGraphto_directeddictr
   copypopr   add_noder   update	enumerateadd_edge)r   r   r	   r   r
   r   r   mappingr   	node_datanodeisourcetdatatarget_datatargetkys                    r   r   r   T   s   R ,
33Jxx
H--H 

 $!!##
+C 
2$$eElCtxx,,--EKG'] , ,FFHH	}}S!!ttD  ++++${+,, > >1 		> 		>E**,,K __S))F >vv...ff%,,[9999 __S$//vv2666ff%b)00====		> Lr    )networkxr   __all___attrsr   _dispatchabler    r    r   <module>r=      s       .
/U	#	# # I I I IX T222#(T G G G 32G G Gr    