(self)
| 217 | assert 0 |
| 218 | |
| 219 | def _linearize_edges(self): |
| 220 | # compute "linear" edges. the idea is that long chains of edges without |
| 221 | # any of the intermediate states being final or any extra incoming or |
| 222 | # outgoing edges can be represented by having removing them, and |
| 223 | # instead using longer strings as edge labels (instead of single |
| 224 | # characters) |
| 225 | incoming = defaultdict(list) |
| 226 | nodes = sorted(self.enum_all_nodes(), key=lambda e: e.id) |
| 227 | for node in nodes: |
| 228 | for label, child in sorted(node.edges.items()): |
| 229 | incoming[child].append(node) |
| 230 | for node in nodes: |
| 231 | node.linear_edges = [] |
| 232 | for label, child in sorted(node.edges.items()): |
| 233 | s = [label] |
| 234 | while len(child.edges) == 1 and len(incoming[child]) == 1 and not child.final: |
| 235 | (c, child), = child.edges.items() |
| 236 | s.append(c) |
| 237 | node.linear_edges.append((''.join(s), child)) |
| 238 | |
| 239 | def _topological_order(self): |
| 240 | # compute reachable linear nodes, and the set of incoming edges for each node |
no test coverage detected