zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
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
U
K±d–ã@sHdZddlZddlmZddlmZmZd dd„Zd dd    „Zd
d „Z    dS)zg
altgraph.GraphUtil - Utility classes and functions
==================================================
éN)Údeque)ÚGraphÚ
GraphErrorFc
Csªt ¡}|s6|r||}n ||d}||kr6tdƒ‚t|ƒ}|D]}| |¡qBt |¡}t |¡}    ||    krt|stqR| ||    ¡dk    rŠ|sŠqR| ||    ¡| ¡|krRq¦qR|S)zŽ
    Generates and returns a :py:class:`~altgraph.Graph.Graph` instance with
    *node_num* nodes randomly connected by *edge_num* edges.
    éz1inconsistent arguments to 'generate_random_graph'N)    rrÚrangeÚadd_nodeÚrandomÚchoiceÚ edge_by_nodeÚadd_edgeZnumber_of_edges)
Znode_numZedge_numÚ
self_loopsÚ multi_edgesÚgZ    max_edgesZnodesÚnodeÚheadÚtail©rúId:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\altgraph/GraphUtil.pyÚgenerate_random_graph s(
 
 
   rc
CsÚt ¡}g}t|ƒD]8}t|d|ƒD]$}| |¡| |¡| ||¡q&qt|||ƒD]x}| |¡| |¡|kr°t |¡}    ||    kr|sqj| ||    ¡r¢|s¢qj| ||    ¡qj|     |¡D]}    | |¡| |    ¡qºq\|S)a˜
    Generates and returns a :py:class:`~altgraph.Graph.Graph` instance that
    will have *steps* \* *growth_num* nodes and a scale free (powerlaw)
    connectivity. Starting with a fully connected graph with *growth_num*
    nodes at every step *growth_num* nodes are added to the graph and are
    connected to existing nodes with a probability proportional to the degree
    of these existing nodes.
    r)
rrÚappendr rZ
out_degreerr    r
Zout_nbrs)
ZstepsZ
growth_numr r ÚgraphÚstoreÚiÚjrZnbrrrrÚgenerate_scale_free_graph5s(
 
 
 
 
 
rcsä|htƒtƒ}‰}t||fgƒ}|j}|j}|j}|rÈ| ¡\}    }
||
ƒ} | dk    rz|D]} | | ƒsZˆ |
¡qzqZ|
}    ||
ƒD]B} || ƒ}|    |
k    r¤| |    |f¡||kr‚| |¡| |    |f¡q‚q6‡fdd„|Dƒ}|ˆ|fS)aÄ
    Perform a walk in a depth-first order starting
    at *head*.
 
    Returns (visited, removes, orphans).
 
    * visited: the set of visited nodes
    * removes: the list of nodes where the node
      data does not all *filters*
    * orphans: tuples of (last_good, node),
      where node is not in removes, is directly
      reachable from a node in *removes* and
      *last_good* is the closest upstream node that is not
      in *removes*.
    Ncs g|]\}}|ˆkr||f‘qSrr)Ú.0ZlgÚtl©ZremovesrrÚ
<listcomp>‰sz filter_stack.<locals>.<listcomp>)ÚsetrZ    node_dataZ    out_edgesrÚpopÚaddr)rrÚfiltersÚvisitedZorphansÚstackÚget_dataZ    get_edgesZget_tailZ    last_goodrÚdataZfiltfuncZedgerrrrÚ filter_stack`s. 
 
r')FF)FF)
Ú__doc__rÚ collectionsrZaltgraphrrrrr'rrrrÚ<module>s  
)
+