ebg_nodes is a run-length-encoded list of nodes. The start nodes in the hsgr edge list are are sorted, ascending, with duplicates. The first entry in ebg_nodes contains the position where the first node starts in ebg_edges, the second entry the position where the second node starts, etc
(ebg_nodes, ebg_edges)
| 149 | |
| 150 | |
| 151 | def expand_nodes(ebg_nodes, ebg_edges): |
| 152 | """ebg_nodes is a run-length-encoded list of nodes. |
| 153 | |
| 154 | The start nodes in the hsgr edge list are are sorted, ascending, with duplicates. |
| 155 | The first entry in ebg_nodes contains the position where the first node starts in |
| 156 | ebg_edges, the second entry the position where the second node starts, etc.""" |
| 157 | node = -1 |
| 158 | (next_node,) = next(ebg_nodes) |
| 159 | for pos, e in enumerate(ebg_edges): |
| 160 | while pos == next_node: |
| 161 | node += 1 |
| 162 | (next_node,) = next(ebg_nodes) |
| 163 | e.source = node |
| 164 | yield e |
| 165 | |
| 166 | |
| 167 | def read_hsgr_file(args): |