@Test public void split() { new GraphFactory() .connect("a", "b1").connect("b1", "c") .connect("a", "b2").connect("b2", "c") .isDag(); }
public boolean isDag() { DirectedGraph<T, Pair> graph = new DefaultDirectedGraph<>(Pair.class); Set<? extends T> initialNodes = initialNodes(); Set<T> knownNodes = new HashSet<>(initialNodes.size() * 10); Deque<T> nodePath = new ArrayDeque<>(20); boolean isDag = tryAdd(initialNodes, graph, knownNodes, new CycleDetector<>(graph), nodePath); if (!isDag) { this.badNodes = nodePath; } return isDag; }
DagChecker { public boolean isDag() { DirectedGraph<T, Pair> graph = new DefaultDirectedGraph<>(Pair.class); Set<? extends T> initialNodes = initialNodes(); Set<T> knownNodes = new HashSet<>(initialNodes.size() * 10); Deque<T> nodePath = new ArrayDeque<>(20); boolean isDag = tryAdd(initialNodes, graph, knownNodes, new CycleDetector<>(graph), nodePath); if (!isDag) { this.badNodes = nodePath; } return isDag; } }
DagChecker { public boolean isDag() { DirectedGraph<T, Pair> graph = new DefaultDirectedGraph<>(Pair.class); Set<? extends T> initialNodes = initialNodes(); Set<T> knownNodes = new HashSet<>(initialNodes.size() * 10); Deque<T> nodePath = new ArrayDeque<>(20); boolean isDag = tryAdd(initialNodes, graph, knownNodes, new CycleDetector<>(graph), nodePath); if (!isDag) { this.badNodes = nodePath; } return isDag; }  }
DagChecker { public boolean isDag() { DirectedGraph<T, Pair> graph = new DefaultDirectedGraph<>(Pair.class); Set<? extends T> initialNodes = initialNodes(); Set<T> knownNodes = new HashSet<>(initialNodes.size() * 10); Deque<T> nodePath = new ArrayDeque<>(20); boolean isDag = tryAdd(initialNodes, graph, knownNodes, new CycleDetector<>(graph), nodePath); if (!isDag) { this.badNodes = nodePath; } return isDag; }  boolean isDag(); List<T> getBadNodePath(); }
DagChecker { public boolean isDag() { DirectedGraph<T, Pair> graph = new DefaultDirectedGraph<>(Pair.class); Set<? extends T> initialNodes = initialNodes(); Set<T> knownNodes = new HashSet<>(initialNodes.size() * 10); Deque<T> nodePath = new ArrayDeque<>(20); boolean isDag = tryAdd(initialNodes, graph, knownNodes, new CycleDetector<>(graph), nodePath); if (!isDag) { this.badNodes = nodePath; } return isDag; }  boolean isDag(); List<T> getBadNodePath();  }