/** * Update as if a new edge is added. * * @param sourceVertex the source vertex * @param targetVertex the target vertex */ private void updateDag(V sourceVertex, V targetVertex) throws CycleFoundException { Integer lb = topoOrderMap.getTopologicalIndex(targetVertex); Integer ub = topoOrderMap.getTopologicalIndex(sourceVertex); if (lb < ub) { Set<V> df = new HashSet<>(); Set<V> db = new HashSet<>(); // discovery Region affectedRegion = new Region(lb, ub); VisitedStrategy visited = visitedStrategyFactory.getVisitedStrategy(affectedRegion); // throws CycleFoundException if there is a cycle dfsF(targetVertex, df, visited, affectedRegion); dfsB(sourceVertex, db, visited, affectedRegion); reorder(df, db, visited); /* * if we do a reorder, then the topology has been updated */ ++topoModCount; } }