+
    )i'                         R t ^ RIHt ^ RIt^ RIHt . ROt]! ^RR7      R 4       t]! ^ RR7      ]P                  ! RRR	R
7      R 4       4       t
]P                  ! RR	R7      R 4       tR tRR ltRR ltR# )a  
*****
Pydot
*****

Import and export NetworkX graphs in Graphviz dot format using pydot.

Either this module or nx_agraph can be used to interface with graphviz.

Examples
--------
>>> G = nx.complete_graph(5)
>>> PG = nx.nx_pydot.to_pydot(G)
>>> H = nx.nx_pydot.from_pydot(PG)

See Also
--------
 - pydot:         https://github.com/erocarrera/pydot
 - Graphviz:      https://www.graphviz.org
 - DOT Language:  http://www.graphviz.org/doc/info/lang.html
)getpreferredencodingN)	open_filew)modec                Z    \        V 4      pVP                  VP                  4       4       R# )zWrite NetworkX graph G to Graphviz dot format on path.

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

path : string or file
   Filename or file handle for data output.
   Filenames ending in .gz or .bz2 will be compressed.
N)to_pydotwrite	to_string)GpathPs   && W/var/www/html/photoedit/myenv/lib/python3.14/site-packages/networkx/drawing/nx_pydot.py	write_dotr   &   s"     	AJJq{{}
    rpydot_read_dotT)namegraphsreturns_graphc                p    ^ RI pV P                  4       pVP                  V4      p\        V^ ,          4      # )aQ  Returns a NetworkX :class:`MultiGraph` or :class:`MultiDiGraph` from the
dot file with the passed path.

If this file contains multiple graphs, only the first such graph is
returned. All graphs _except_ the first are silently ignored.

Parameters
----------
path : str or file
    Filename or file handle to read.
    Filenames ending in .gz or .bz2 will be decompressed.

Returns
-------
G : MultiGraph or MultiDiGraph
    A :class:`MultiGraph` or :class:`MultiDiGraph`.

Notes
-----
Use `G = nx.Graph(nx.nx_pydot.read_dot(path))` to return a :class:`Graph` instead of a
:class:`MultiGraph`.
N)pydotreadgraph_from_dot_data
from_pydot)r   r   dataP_lists   &   r   read_dotr   7   s5    2 99;D &&t,F fQi  r   )r   r   c                N    V P                  4       pV'       * pV P                  4       R8X  d5   V'       d   \        P                  ! 4       pMI\        P
                  ! 4       pM3V'       d   \        P                  ! 4       pM\        P                  ! 4       pV P                  4       P                  R4      pVR8w  d   WCn
        V P                  4        FL  pVP                  4       P                  R4      pVR9   d   K+  VP                  ! V3/ VP                  4       B  KN  	  V P                  4        EF,  pVP                  4       pVP!                  4       p	VP                  4       p
. p. p\#        V\$        4      '       d"   VP'                  VP                  R4      4       M0VR,           F#  pVP'                  VP                  R4      4       K%  	  \#        V	\$        4      '       d"   VP'                  V	P                  R4      4       M0V	R,           F#  pVP'                  VP                  R4      4       K%  	  V F   pV F  pVP(                  ! VV3/ V
B  K  	  K"  	  EK/  	  V P                  4       pV'       d   VVP*                  R&    V P-                  4       ^ ,          VP*                  R&    V P1                  4       ^ ,          VP*                  R&   V#   \         d    T P                  R4      p ELi ; i  \.        \        3 d     L]i ; i  \.        \        3 d     T# i ; i)	a  Returns a NetworkX graph from a Pydot graph.

Parameters
----------
P : Pydot graph
  A graph created with Pydot

Returns
-------
G : NetworkX multigraph
    A MultiGraph or MultiDiGraph.

Examples
--------
>>> K5 = nx.complete_graph(5)
>>> A = nx.nx_pydot.to_pydot(K5)
>>> G = nx.nx_pydot.from_pydot(A)  # return MultiGraph

# make a Graph instead of MultiGraph
>>> G = nx.Graph(nx.nx_pydot.from_pydot(A))

Ngraph" nodeedgenodes)r!   r   r"   )
get_strict	TypeErrorget_typenx
MultiGraphGraphMultiDiGraphDiGraphget_namestripr   get_node_listadd_nodeget_attributesget_edge_list
get_sourceget_destination
isinstancestrappendadd_edger   get_node_defaults
IndexErrorget_edge_defaults)r   strict
multiedgesNr   pneuvattrsdunodesvnodessource_nodedestination_nodepattrs   &                 r   r   r   [   s   4$ Jzz|wA
A!A

A ::<c"Drz __JJLs#))	

1+((*+	  __LLN!aHHQWWS\"G**c*+ % aHHQWWS\"G**c*+ % K$% 

;(8ADA %& ' 0 E --/2--/2 H  $d#$r 	"  	" Hs5   K 
$K8 /$L K54K58LLL$#L$c           	        ^ RI pV P                  4       '       d   RpMRp\        P                  ! V 4      ^ 8H  ;'       d    V P	                  4       '       * pV P
                  pV P                  P                  R/ 4      pVR8X  d   VP                  ! RRVRV/VB pMVP                  ! RV R23RVRV/VB p VP                  ! R/ V P                  R,          B   VP                  ! R/ V P                  R	,          B  V P                  R
R7       Fj  w  rxVP                  4        U	U
u/ uF  w  r\        V	4      \        V
4      bK  	  pp	p
\        V4      pVP                  ! V3/ VB pVP!                  V4       Kl  	  V P	                  4       '       d   V P#                  R
R
R7       F  w  rrVP                  4        U	U
u/ uF#  w  rV	R8w  g   K  \        V	4      \        V
4      bK%  	  pp	p
\        V4      \        X
4      rVP$                  ! W3R\        V4      /VB pVP'                  V4       K  	  V# V P#                  R
R7       Fu  w  rpVP                  4        U	U
u/ uF  w  r\        V	4      \        V
4      bK  	  pp	p
\        V4      \        X
4      rVP$                  ! W3/ VB pVP'                  V4       Kw  	  V#   \         d     ELi ; i  \         d     ELi ; iu up
p	i u up
p	i u up
p	i )zReturns a pydot graph from a NetworkX graph N.

Parameters
----------
N : NetworkX graph
  A graph created with NetworkX

Examples
--------
>>> K5 = nx.complete_graph(5)
>>> P = nx.nx_pydot.to_pydot(K5)

Notes
-----

Ndigraphr   r    
graph_typer;   r   r!   r"   T)r   )r   keyskey)r     )r   is_directedr'   number_of_selfloopsis_multigraphr   r   getDotset_node_defaultsKeyErrorset_edge_defaultsr#   itemsr5   Noder/   edgesEdger7   )r=   r   rM   r;   r   graph_defaultsr   r?   nodedatakrB   str_nodedatar>   rA   rO   edgedatastr_edgedatar"   s   &                 r   r   r      s   "  	}}

##A&!+EEAOO4E0EF66DWW[["-NrzIIQZQQ.QIIvQK
$.
7=
AO
	.aggfo.	.aggfo. wwDw)3;>>3CD3C41AA3CDFJJq)L)	

1	 * 	#$7747#@A#7?~~7GV7Gtq1PU:NCFCFN7GLVq63q6q::aACALADJJt	 $A H  gg4g0NA(7?~~7GH7GtqCFCFN7GLHq63q6q::a3l3DJJt	 1
 H5     E W Is<   8#K #K ) K(K.K." K4KKK%$K%c                    \        WVR7      # )a  Create node positions using Pydot and Graphviz.

Returns a dictionary of positions keyed by node.

Parameters
----------
G : NetworkX Graph
    The graph for which the layout is computed.
prog : string (default: 'neato')
    The name of the GraphViz program to use for layout.
    Options depend on GraphViz version but may include:
    'dot', 'twopi', 'fdp', 'sfdp', 'circo'
root : Node from G or None (default: None)
    The node of G from which to start some layout algorithms.

Returns
-------
  Dictionary of (x, y) positions keyed by node.

Examples
--------
>>> G = nx.complete_graph(4)
>>> pos = nx.nx_pydot.graphviz_layout(G)
>>> pos = nx.nx_pydot.graphviz_layout(G, prog="dot")

Notes
-----
This is a wrapper for pydot_layout.
r
   progroot)pydot_layoutrd   s   &&&r   graphviz_layoutrh      s    < !T22r   c                   ^ RI p\        V 4      pVe   VP                  R\        V4      4       VP	                  VR7      p\        V\        4       R7      pVR8X  dL   \        RV R24       \        4        \        R4       \        R	4       \        R
4       \        RV R24       R# VP                  V4      p\        V4      ^8X  g   Q hV^ ,          p/ p	V P                  4        F  p
\        V
4      pVP                  VP                  V4      4      p\        V\        4      '       d
   V^ ,          pVP                  4       ^R pVf   Kf  VP                  R4      w  r\!        V4      \!        V4      3W&   K  	  V	# )a|  Create node positions using :mod:`pydot` and Graphviz.

Parameters
----------
G : Graph
    NetworkX graph to be laid out.
prog : string  (default: 'neato')
    Name of the GraphViz command to use for layout.
    Options depend on GraphViz version but may include:
    'dot', 'twopi', 'fdp', 'sfdp', 'circo'
root : Node from G or None (default: None)
    The node of G from which to start some layout algorithms.

Returns
-------
dict
    Dictionary of positions keyed by node.

Examples
--------
>>> G = nx.complete_graph(4)
>>> pos = nx.nx_pydot.pydot_layout(G)
>>> pos = nx.nx_pydot.pydot_layout(G, prog="dot")

Notes
-----
If you use complex node objects, they may have the same string
representation and GraphViz could treat them as the same node.
The layout may assign both nodes a single location. See Issue #1568
If this occurs in your case, consider relabeling the nodes just
for the layout computation using something similar to::

    H = nx.convert_node_labels_to_integers(G, label_attribute="node_label")
    H_layout = nx.nx_pydot.pydot_layout(H, prog="dot")
    G_layout = {H.nodes[n]["node_label"]: p for n, p in H_layout.items()}

Nrf   )re   )encodingr    zGraphviz layout with z failedzTo debug what happened try:zP = nx.nx_pydot.to_pydot(G)zP.write_dot("file.dot")zAnd then run z on file.dot,)r   r   setr5   
create_dotr   printr   lenr#   get_nodequote_id_if_necessaryr4   listget_possplitfloat)r
   re   rf   r   r   D_bytesDQ_listQnode_posr?   str_nr!   posxxyys   &&&             r   rg   rg     sW   L A	fc$i  lll%G 	G245ABw%dV734+,+,'(dV<01 &&q)Fv;! 	q	AHWWYAzz%55e<=dD!!7DllnQr"?YYs^FB 9eBi0HK  Or   )r   r   rh   rg   r   r   )neatoN)__doc__localer   networkxr'   networkx.utilsr   __all__r   _dispatchabler   r   r   rh   rg   rP   r   r   <module>r      s   , (  $ 13   13'DI! J !D T2Z 3Zz>B3BNr   