+
    )i                     d    ^ RI Ht ^ RItRR.tR	R lt]P                  ! RRR7      R	R l4       tR# )
    )chainN	tree_data
tree_graphc                  aaa V P                  4       V P                  4       ^,           8w  d   \        R4      hV P                  4       '       g   \        R4      h\        P
                  ! V 4      '       g   \        R4      hSS8X  d   \        P                  ! R4      hVVV3R lo/ V P                  V,          CSVSS! W4      /C# )ai  Returns data in tree format that is suitable for JSON serialization
and use in JavaScript documents.

Parameters
----------
G : NetworkX graph
   G must be an oriented tree

root : node
   The root of the tree

ident : string
    Attribute name for storing NetworkX-internal graph data. `ident` must
    have a different value than `children`. The default is 'id'.

children : string
    Attribute name for storing NetworkX-internal graph data. `children`
    must have a different value than `ident`. The default is 'children'.

Returns
-------
data : dict
   A dictionary with node-link formatted data.

Raises
------
NetworkXError
    If `children` and `ident` attributes are identical.

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

To serialize with json

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

Notes
-----
Node attributes are stored in this format but keys
for attributes must be strings if you want to serialize with JSON.

Graph and edge attributes are not stored.

See Also
--------
tree_graph, node_link_data, adjacency_data
zG is not a tree.zG is not directed.zG is not weakly connected.z5The values for `id` and `children` must be different.c                    < W,          p\        V4      ^ 8X  d   . # . pV FA  p/ VP                  V,          CS	V/CpS! WA4      pV'       d   WeS&   VP                  V4       KC  	  V# )r   )lennodesappend)
nGnbrs	children_childdcadd_childrenchildrenidents
   &&     `/var/www/html/photoedit/myenv/lib/python3.14/site-packages/networkx/readwrite/json_graph/tree.pyr   tree_data.<locals>.add_childrenF   sl    tt9>I	E01775>05%0AU&A(Q      )number_of_nodesnumber_of_edges	TypeErroris_directednxis_weakly_connectedNetworkXErrorr	   )r   rootr   r   r   s   &&ff@r   r   r      s    h 	a//1A55*++==??,--!!!$$455VWW KaggdmJUD(L4IJJr   T)graphsreturns_graphc                @  aaaa	 \         P                  ! 4       o	VVV	V3R loV S,          pV P                  S. 4      pV P                  4        UUu/ uF#  w  rVVS8w  g   K  VS8w  g   K  \	        V4      VbK%  	  pppS	P
                  ! V3/ VB  S! W44       S	# u uppi )a  Returns graph from tree data format.

Parameters
----------
data : dict
    Tree formatted graph data

ident : string
    Attribute name for storing NetworkX-internal graph data. `ident` must
    have a different value than `children`. The default is 'id'.

children : string
    Attribute name for storing NetworkX-internal graph data. `children`
    must have a different value than `ident`. The default is 'children'.

Returns
-------
G : NetworkX DiGraph

Examples
--------
>>> from networkx.readwrite import json_graph
>>> G = nx.DiGraph([(1, 2)])
>>> data = json_graph.tree_data(G, root=1)
>>> H = json_graph.tree_graph(data)

See Also
--------
tree_data, node_link_data, adjacency_data
c                 B  < V F  pVS,          pS
P                  W4       VP                  S	. 4      pV'       d	   S! W44       VP                  4        UUu/ uF#  w  rVVS8w  g   K  VS	8w  g   K  \        V4      VbK%  	  pppS
P                  ! V3/ VB  K  	  R # u uppi )N)add_edgegetitemsstradd_node)parentr   datar   grandchildrenkvnodedatar   r   graphr   s   &&      r   r    tree_graph.<locals>.add_childrenx   s    DKENN6) HHXr2MU2&*jjl&2daa5j	Q(]	A	l   NN5-H- s   B&B/B)r   DiGraphr%   r&   r'   r(   )
r*   r   r   r   r   r,   r-   r.   r   r/   s
   &ff     @@r   r   r   V   s    @ JJLE
. 
. ;D2&I&*jjlSldaa5j	Q(]	A	lHS	NN4$8$!L Ts   B!B*B)idr   )	itertoolsr   networkxr   __all__r   _dispatchabler    r   r   <module>r8      s>     
%KK\ T22 32r   