hyb
2026-01-07 c7f60dc7e9a36596f0e0d1787bd0cca4e9b57bcb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
Ë
?ñúhÉ&ãó:—dZddlZddlZddlmZGd„de«Zy)a
 
altgraph.Dot - Interface to the dot language
============================================
 
The :py:mod:`~altgraph.Dot` module provides a simple interface to the
file format used in the
`graphviz <http://www.research.att.com/sw/tools/graphviz/>`_
program. The module is intended to offload the most tedious part of the process
(the **dot** file generation) while transparently exposing most of its
features.
 
To display the graphs or to generate image files the
`graphviz <http://www.research.att.com/sw/tools/graphviz/>`_
package needs to be installed on the system, moreover the :command:`dot` and
:command:`dotty` programs must be accesible in the program path so that they
can be ran from processes spawned within the module.
 
Example usage
-------------
 
Here is a typical usage::
 
    from altgraph import Graph, Dot
 
    # create a graph
    edges = [ (1,2), (1,3), (3,4), (3,5), (4,5), (5,4) ]
    graph = Graph.Graph(edges)
 
    # create a dot representation of the graph
    dot = Dot.Dot(graph)
 
    # display the graph
    dot.display()
 
    # save the dot representation into the mydot.dot file
    dot.save_dot(file_name='mydot.dot')
 
    # save dot file as gif image into the graph.gif file
    dot.save_img(file_name='graph', file_type='gif')
 
Directed graph and non-directed graph
-------------------------------------
 
Dot class can use for both directed graph and non-directed graph
by passing ``graphtype`` parameter.
 
Example::
 
    # create directed graph(default)
    dot = Dot.Dot(graph, graphtype="digraph")
 
    # create non-directed graph
    dot = Dot.Dot(graph, graphtype="graph")
 
Customizing the output
----------------------
 
The graph drawing process may be customized by passing
valid :command:`dot` parameters for the nodes and edges. For a list of all
parameters see the `graphviz <http://www.research.att.com/sw/tools/graphviz/>`_
documentation.
 
Example::
 
    # customizing the way the overall graph is drawn
    dot.style(size='10,10', rankdir='RL', page='5, 5' , ranksep=0.75)
 
    # customizing node drawing
    dot.node_style(1, label='BASE_NODE',shape='box', color='blue' )
    dot.node_style(2, style='filled', fillcolor='red')
 
    # customizing edge drawing
    dot.edge_style(1, 2, style='dotted')
    dot.edge_style(3, 5, arrowhead='dot', label='binds', labelangle='90')
    dot.edge_style(4, 5, arrowsize=2, style='bold')
 
 
.. note::
 
   dotty (invoked via :py:func:`~altgraph.Dot.display`) may not be able to
   display all graphics styles. To verify the output save it to an image file
   and look at it that way.
 
Valid attributes
----------------
 
    - dot styles, passed via the :py:meth:`Dot.style` method::
 
        rankdir = 'LR'   (draws the graph horizontally, left to right)
        ranksep = number (rank separation in inches)
 
    - node attributes, passed via the :py:meth:`Dot.node_style` method::
 
        style = 'filled' | 'invisible' | 'diagonals' | 'rounded'
        shape = 'box' | 'ellipse' | 'circle' | 'point' | 'triangle'
 
    - edge attributes, passed via the :py:meth:`Dot.edge_style` method::
 
        style     = 'dashed' | 'dotted' | 'solid' | 'invis' | 'bold'
        arrowhead = 'box' | 'crow' | 'diamond' | 'dot' | 'inv' | 'none'
            | 'tee' | 'vee'
        weight    = number (the larger the number the closer the nodes will be)
 
    - valid `graphviz colors
        <http://www.research.att.com/~erg/graphviz/info/colors.html>`_
 
    - for more details on how to control the graph drawing process see the
      `graphviz reference
        <http://www.research.att.com/sw/tools/graphviz/refs.html>`_.
éN)Ú
GraphErrorcóh—eZdZdZ                                        d d„Zd„Zdd„Zd„Zd„Zd„Z    d    „Z
d
„Z dd „Z dd „Z y)ÚDota0
    A  class providing a **graphviz** (dot language) representation
    allowing a fine grained control over how the graph is being
    displayed.
 
    If the :command:`dot` and :command:`dotty` programs are not in the current
    system path their location needs to be specified in the contructor.
    Nc óZ‡—|ic|_|_|
dvsJ‚|
|_d|_d|_|||    c|_|_|_iic|_|_    ||€|}||€|fd„}|€d}t«Š|D]E} |€i} n|| «} | €Œi|j| <|j| fi| ¤Ž‰j| «ŒG|r‰D]l} ˆfd„|| «D«D]V}|€i}n    || |«}|€Œ| |jvri|j| <i|j| |<|j| |fi|¤ŽŒXŒnyy)z!
        Initialization.
        )ÚgraphÚdigraphz tmp_dot.dotz tmp_neo.dotNcó$—|j|«S©N)Úout_nbrs)Únoders  ú?H:\Change_password\venv_build\Lib\site-packages\altgraph/Dot.pyÚedgefnzDot.__init__.<locals>.edgefn¡s€Ø—~‘~ dÓ+Ð+ó©c3ó,•K—|] }|‰vsŒ|–—Œ y­wr
r)Ú.0ÚnÚseens  €r ú    <genexpr>zDot.__init__.<locals>.<genexpr>³søèø€ÒB 1¸¸Tº    œQÑBùsƒ    )ÚnameÚattrÚtypeÚtemp_dotÚtemp_neoÚdotÚdottyÚneatoÚnodesÚedgesÚsetÚ
node_styleÚaddÚ
edge_style)ÚselfrrrÚ nodevisitorÚ edgevisitorrrrrÚ    graphtyper ÚstyleÚheadÚtailÚ    edgestylers                @r Ú__init__z Dot.__init__s‚ø€ð  $ RЈŒ    4”9àÐ0Ñ0Ð0Ð0؈Œ    à%ˆŒ Ø%ˆŒ à+.°°uÐ(ˆŒ$”*˜dœjð"$ RЈŒ
D”Jà Ð   ØˆEØ Ð   à#(ó ,ð ˆ=؈Eä‹uˆØò    ˆDØÐ"Ø‘á# DÓ)ØÑ Ø#%—
‘
˜4Ѡؐ—‘ Ñ.¨Ò.Ø—‘˜•ð    ð Ð Øò
AÛB©¨t« ÔBò    ADØ"Ð*Ø$&™    á$/°°dÓ$;˜    Ø Ñ,Ø t§z¡zÑ1Ø/1˜DŸJ™J tÑ,Ø13˜Ÿ
™
 4Ñ(¨Ñ.Ø'˜Ÿ™¨¨dÑ@°iÓ@ñ    Añ
Að rc ó—||_y)z+
        Changes the overall style
        N)r)r$rs  r r(z    Dot.style¾s €ðˆ    rcóV—|dk(rY|j|j«|j›d|j›d|j›}t    j
|«n|j|j«|j ›d|j›}t    j
|«y)z6
        Displays the current graph via dotty
        rú -o ú N)Úsave_dotrrrÚosÚsystemr)r$ÚmodeÚ    neato_cmdÚplot_cmds    r Údisplayz Dot.displayÄsm€ð
7Š?Ø M‰M˜$Ÿ-™-Ô (Ø)-¯«°T·]³]ÀDÇMÂMÐRˆIÜ I‰IiÕ  à M‰M˜$Ÿ-™-Ô (à"Ÿj›j¨$¯-ª-Ð8ˆÜ
    ‰    (Õrc ó\—||jvri|j|<||j|<y)zB
        Modifies a node style to the dot representation.
        N)rr)r$r Úkwargss   r r!zDot.node_styleÓs,€ð t—z‘zÑ !Ø!ˆDJ‰JtÑ Ø!ˆ
‰
4Òrc óL—|jD]}|j|fi|¤ŽŒy)z*
        Modifies all node styles
        N)rr!)r$r9r s   r Úall_node_stylezDot.all_node_styleÛs*€ð—J‘Jò    ,ˆDØ ˆDO‰O˜DÑ + FÓ +ñ    ,rc óæ—||jvrtd|›«‚    ||j|vri|j||<||j||<y#t$rtd|›d|›d«‚wxYw)zC
        Modifies an edge style to the dot representation.
        z invalid node zinvalid edge  z -> r0N)rrrÚKeyError)r$r)r*r9s    r r#zDot.edge_styleâs|€ð t—z‘zÑ !ݱ$Ð8Ó9Ð 9ð    Gؘ4Ÿ:™: dÑ+Ñ+Ø)+—
‘
˜4Ñ  Ñ&Ø%+ˆDJ‰JtÑ ˜TÒ "øÜò    Gݺ$ÂÐEÓFÐ Fð    Gús ž5AÁA0c#ó>K—|jdk(rd|j›d–—n:|jdk(rd|j›d–—ntd|j›«‚t|jj ««D]\}}|›d|›d–—Œd    –—d
}d }t|j j ««D];\}}d |›d –—t|j ««D]\}}|||fz–—Œ|–—Œ=t|j«D]ƒ}t|j|«D]f}|jdk(r d |›d|›d –—n d |›d|›d –—t|j||j ««D]\}}|||fz–—Œ|–—ŒhŒ…d–—y­w)Nrzdigraph z {
rzgraph zunsupported graphtype z="z";ú
z%s="%s",z];
z    "z" [z" -> "z" -- "z}
)rrrÚsortedrÚitemsrr)    r$Ú    attr_nameÚ
attr_valueÚcpattÚepattÚ    node_nameÚ    node_attrr)r*s             r Úiterdotz Dot.iterdotðs èø€à 9‰9˜    Ó !Ø&*§i£iÐ1Ó 1Ø Y‰Y˜'Ó !Ø$(§I£IÐ/Ó /õ¸4¿9º9ÐFÓGÐ Gô&,¨D¯I©I¯O©OÓ,=Ó%>ò    7Ñ !ˆIzÚ )ª:Ð6Ó 6ð    7àŠ
ðˆØˆô%+¨4¯:©:×+;Ñ+;Ó+=Ó$>ò    Ñ  ˆI‘yÚ )Ð+Ò +Ü)/°    ·±Ó0AÓ)Bò 6Ñ%    ˜:ؘy¨*Ð5Ñ5Ó5ð 6à‹Kð        ô˜4Ÿ:™:Ó&ò    ˆDܘtŸz™z¨$Ñ/Ó0ò Ø—9‘9     Ó)Ú04²dÐ;Ó;ð*ò15²dÐ;Ò;Ü-3°D·J±J¸tÑ4DÀTÑ4J×4PÑ4PÓ4RÓ-Sò:Ñ)I˜zØ 9¨jÐ"9Ñ9Ó9ð:à“ ñ ð    ð‹ ùs‚FFcó"—|j«Sr
)rH)r$s r Ú__iter__z Dot.__iter__s€Ø|‰|‹~Ðrcóè—|s(tjtdd¬«|j}t    |d«5}|j «D]}|j |«Œ    ddd«y#1swYyxYw)zD
        Saves the current graph representation into a file
        úalways pass a file_nameé©Ú
stacklevelÚwN)ÚwarningsÚwarnÚDeprecationWarningrÚopenrHÚwrite)r$Ú    file_nameÚfpÚchunks    r r1z Dot.save_dotsd€ñ
Ü M‰MÔ,Ð.GÐTUÕ VØŸ ™ ˆIä )˜SÓ !ð      RØŸ™›ò  Ø—‘˜•ñ  ÷     ÷     ñ     ús ·'A(Á(A1cóÌ—|stjtdd¬«d}|dk(re|j|j«|j
›d|j ›d|j›}tj|«|j}n'|j|j «|j}|›d|›}|›d    |›d|j ›d|›}tj|«y
) z5
        Saves the dot file as an image file
        rLrMrNÚoutrr/r0ú.z -TN)
rQrRrSr1rrrr2r3r)r$rVÚ    file_typer4r5r6Ú
create_cmds       r Úsave_imgz Dot.save_img(s«€ñ
Ü M‰MÔ,Ð.GÐTUÕ V؈Ià 7Š?Ø M‰M˜$Ÿ-™-Ô (Ø)-¯«°T·]³]ÀDÇMÂMÐRˆIÜ I‰IiÔ  Ø—x‘x‰Hà M‰M˜$Ÿ-™-Ô (Ø—x‘xˆHâ(©)Ð4ˆ    â Ú Ø M‹MÙ ð    
ˆ
ô          ‰    *Õr)
NNNNNÚGrrrr)rr
)NÚgifr)Ú__name__Ú
__module__Ú __qualname__Ú__doc__r,r(r7r!r;r#rHrJr1r^rrr rrus]„ñðØØØØØ Ø ØØØó=Aò~ó ò"ò,ò Gò&òPó  ôrr)rdr2rQÚaltgraphrÚobjectrrrr ú<module>rgs%ðñmó\
ÛåôLˆ&õLr