end
end
-function DAG:addEdge(nnma, nnmb)
+-- The main use should be to add an edge between two modules, but it
+-- can also add a full sequence of modules
+function DAG:addEdge(...)
self.sorted = nil
- self:createNode(nnma)
- self:createNode(nnmb)
- table.insert(self.node[nnmb].pred, nnma)
- table.insert(self.node[nnma].succ, nnmb)
+ local prev
+ for _, nnm in pairs({...}) do
+ self:createNode(nnm)
+ if prev then
+ table.insert(self.node[nnm].pred, prev)
+ table.insert(self.node[prev].succ, nnm)
+ end
+ prev = nnm
+ end
end
-- Apply f on t recursively; use the corresponding element from args