@@ -89,11 +89,16 @@ readGraph root name = doesDirectoryExist root >>= \case
8989 False -> do
9090 return Nothing
9191
92−-- | Ensures that the migration class is correct
92+-- | Ensures that the migration graph is correct
93+--
94+-- In a correct migration graph: for all pairs of nodes, all paths between
95+-- those nodes have the same migration value
9396--
9497-- Throw the following if integrity check fails
9598-- * `CyclicGraphError`
9699-- * `NonEquivalentPaths`
100+--
101+-- Complexity: O(V+E)
97102ensureGraphIntegrity
98103 :: (MonadThrow m, Monoid action, Ord action)
99104 => Migration action -> m ()
@@ -111,12 +116,18 @@ ensureGraphIntegrity m = do
111116 then pure visited
112117 else throwM $ NonEquivalentPaths start adj
113118 traverseFrom visited' acc' adj
119+ -- We only check all paths from the _first_ vertex; it is not necessary to
120+ -- check all paths between _all_ pairs of vertices as that can be proved by
121+ -- induction, as long as there is exactly one first vertex (which we check on
122+ -- further above).
114123 traverseFrom mempty mempty firstVertex
115124
116125-- | Find the concataneted actions between two vertices
117126--
118127-- All paths between the vertices must have the same mappend'ed action;
119128-- otherwise this will throw.
129+--
130+-- Complexity: O(V+E)
120131findPathAction
121132 :: (MonadThrow m, Action action, Monoid action, Ord action)
122133 => Migration action -> Hash -> Hash -> m (Maybe action)