Switch to unified view

a/pyforge/flyway/graph.py b/pyforge/flyway/graph.py
...
...
3
3
4
class MigrationGraph(object):
4
class MigrationGraph(object):
5
5
6
    def __init__(self, migrations):
6
    def __init__(self, migrations):
7
        self._build_graph(migrations)
7
        self._build_graph(migrations)
8
9
    def reset(self):
10
        for n in self._nodes: n.reset()
8
11
9
    def _build_graph(self, migrations):
12
    def _build_graph(self, migrations):
10
        '''Build a graph where the nodes are possible migration states and the
13
        '''Build a graph where the nodes are possible migration states and the
11
        edges are transitions between states allowed by migrations.
14
        edges are transitions between states allowed by migrations.
12
        '''
15
        '''
...
...
119
122
120
class Node(object):
123
class Node(object):
121
124
122
    def __init__(self, state):
125
    def __init__(self, state):
123
        self.state = state
126
        self.state = state
127
        self.succs = [] # list of (state, migrationstep)
128
        self.reset()
129
130
    def reset(self):
124
        self.visited = False
131
        self.visited = False
132
        self.pred = None # (state, migrationstep)
125
        self.distance = 1e9 # effectively inf
133
        self.distance = 1e9 # effectively inf
126
        self.pred = None # (state, migrationstep)
127
        self.succs = [] # list of (state, migrationstep)
128
134
129
    def visit(self, nodes):
135
    def visit(self, nodes):
130
        '''The 'visit' step of Dijkstra's shortest-path algorithm'''
136
        '''The 'visit' step of Dijkstra's shortest-path algorithm'''
131
        self.visited = True
137
        self.visited = True
132
        new_dist = self.distance + 1
138
        new_dist = self.distance + 1