A single node in the migration graph. Contains direct links to adjacent nodes in either direction.
| 8 | |
| 9 | @total_ordering |
| 10 | class Node: |
| 11 | """ |
| 12 | A single node in the migration graph. Contains direct links to adjacent |
| 13 | nodes in either direction. |
| 14 | """ |
| 15 | |
| 16 | def __init__(self, key): |
| 17 | self.key = key |
| 18 | self.children = set() |
| 19 | self.parents = set() |
| 20 | |
| 21 | def __eq__(self, other): |
| 22 | return self.key == other |
| 23 | |
| 24 | def __lt__(self, other): |
| 25 | return self.key < other |
| 26 | |
| 27 | def __hash__(self): |
| 28 | return hash(self.key) |
| 29 | |
| 30 | def __getitem__(self, item): |
| 31 | return self.key[item] |
| 32 | |
| 33 | def __str__(self): |
| 34 | return str(self.key) |
| 35 | |
| 36 | def __repr__(self): |
| 37 | return "<%s: (%r, %r)>" % (self.__class__.__name__, self.key[0], self.key[1]) |
| 38 | |
| 39 | def add_child(self, child): |
| 40 | self.children.add(child) |
| 41 | |
| 42 | def add_parent(self, parent): |
| 43 | self.parents.add(parent) |
| 44 | |
| 45 | |
| 46 | class DummyNode(Node): |
no outgoing calls