zmc
2023-10-12 ed135d79df12a2466b52dae1a82326941211dcc9
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
U
I=®dàã@sGdd„deƒZdS)c@speZdZdZdd„Zdd„Zdd„Zdd    „Zd
d „Zd d „Z    dd„Z
dd„Z dd„Z dd„Z dd„Zdd„ZdS)Ú DirectedGraphz+A graph structure with directed edges.
    cCstƒ|_i|_i|_dS©N)ÚsetÚ    _verticesÚ    _forwardsÚ
_backwards©Úself©r    úUD:\z\workplace\VsCode\pyvenv\venv\Lib\site-packages\pip/_vendor/resolvelib/structs.pyÚ__init__szDirectedGraph.__init__cCs
t|jƒSr)Úiterrrr    r    r
Ú__iter__
szDirectedGraph.__iter__cCs
t|jƒSr)Úlenrrr    r    r
Ú__len__ szDirectedGraph.__len__cCs
||jkSr)r©rÚkeyr    r    r
Ú __contains__szDirectedGraph.__contains__cCsBtƒ}t|jƒ|_dd„|j ¡Dƒ|_dd„|j ¡Dƒ|_|S)z-Return a shallow copy of this graph.
        cSsi|]\}}|t|ƒ“qSr    ©r©Ú.0ÚkÚvr    r    r
Ú
<dictcomp>sz&DirectedGraph.copy.<locals>.<dictcomp>cSsi|]\}}|t|ƒ“qSr    rrr    r    r
rs)rrrrÚitemsr)rÚotherr    r    r
Úcopys
 zDirectedGraph.copycCs:||jkrtdƒ‚|j |¡tƒ|j|<tƒ|j|<dS)z'Add a new vertex to the graph.
        z vertex existsN)rÚ
ValueErrorÚaddrrrrr    r    r
rs
 
  zDirectedGraph.addcCsT|j |¡|j |¡D]}|j| |¡q|j |¡D]}|j| |¡q:dS)zLRemove a vertex from the graph, disconnecting all edges from/to it.
        N)rÚremoverÚpopr)rrÚfÚtr    r    r
r%s
 zDirectedGraph.removecCs||j|ko||j|kSr)rr©rr r!r    r    r
Ú    connected.szDirectedGraph.connectedcCs6||jkrt|ƒ‚|j| |¡|j| |¡dS)zgConnect two existing vertices.
 
        Nothing happens if the vertices are already connected.
        N)rÚKeyErrorrrrr"r    r    r
Úconnect1s
zDirectedGraph.connectccs,|j ¡D]\}}|D]}||fVqq
dSr)rr)rr Úchildrenr!r    r    r
Ú
iter_edges;szDirectedGraph.iter_edgescCst|j|ƒSr)r rrr    r    r
Ú iter_children@szDirectedGraph.iter_childrencCst|j|ƒSr)r rrr    r    r
Ú iter_parentsCszDirectedGraph.iter_parentsN)Ú__name__Ú
__module__Ú __qualname__Ú__doc__r r rrrrrr#r%r'r(r)r    r    r    r
rs            
rN)Úobjectrr    r    r    r
Ú<module>ó