public static void main(String[] args) { DiGraph g = new DiGraph(13); g.addEdge(0, 5); g.addEdge(4, 3); g.addEdge(5, 4); g.addEdge(3, 5); CycleDetect detectCycle = new CycleDetect(g); Stack<Integer> st = (Stack<Integer>) detectCycle.cycle(); while (!st.isEmpty()) { System.out.print(st.pop() + " "); } }
public static void main(String args[]) { DiGraph g = new DiGraph(4); g.addEdge(0, 1); g.addEdge(0, 3); g.addEdge(1, 0); g.addEdge(1, 2); g.addEdge(2, 1); g.addEdge(2, 3); g.addEdge(3, 0); g.addEdge(3, 2); BipartiteGraph bipartiteGraph = new BipartiteGraph(g); if (bipartiteGraph.isBipartite(0)) System.out.println("Graph is Bipartite"); else System.out.println("Graph is not Bipartite"); }