mode.utils.graphs
DependencyGraph
Bases: DependencyGraphT
A directed acyclic graph of objects and their dependencies.
Supports a robust topological sort to detect the order in which they must be handled.
Takes an optional iterator of (obj, dependencies)
tuples to build the graph from.
Warning
Does not support cycle detection.
Source code in mode/utils/graphs/graph.py
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 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | |
add_arc(obj)
Add an object to the graph.
Source code in mode/utils/graphs/graph.py
54 55 56 | |
add_edge(A, B)
Add an edge from object A to object B.
I.e. A depends on B.
Source code in mode/utils/graphs/graph.py
58 59 60 61 62 63 | |
connect(graph)
Add nodes from another graph.
Source code in mode/utils/graphs/graph.py
65 66 67 | |
edges()
Return generator that yields for all edges in the graph.
Source code in mode/utils/graphs/graph.py
110 111 112 | |
to_dot(fh, *, formatter=None)
Convert the graph to DOT format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fh |
IO
|
A file, or a file-like object to write the graph to. |
required |
formatter |
GraphFormatter
|
Custom graph formatter to use. |
None
|
Source code in mode/utils/graphs/graph.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |
topsort()
Sort the graph topologically.
Returns:
| Name | Type | Description |
|---|---|---|
List |
Sequence
|
of objects in the order in which they must be handled. |
Source code in mode/utils/graphs/graph.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
update(it)
Update graph with data from a list of (obj, deps) tuples.
Source code in mode/utils/graphs/graph.py
101 102 103 104 105 106 107 108 | |
valency_of(obj)
Return the valency (degree) of a vertex in the graph.
Source code in mode/utils/graphs/graph.py
91 92 93 94 95 96 97 98 99 | |
GraphFormatter
Bases: GraphFormatterT
Format dependency graphs.
Source code in mode/utils/graphs/formatter.py
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 | |