@@ -0,0 +1,2744 @@
+package com.test.graphs;%0A%0Aimport java.util.Collection;%0Aimport java.util.HashSet;%0Aimport java.util.Set;%0A%0Aimport com.graphs.GraphAdjacencyListRepresentation;%0Aimport com.graphs.ReachabilityInGraph;%0A%0Aimport junit.framework.TestCase;%0A%0Apublic class TestReachabilityInGraph extends TestCase %7B%0A%0A    public void testReachabilityInDirectedGraph() %7B%0A        GraphAdjacencyListRepresentation graph = new GraphAdjacencyListRepresentation(13, true);%0A        graph.addEdge(0, 5);%0A        graph.addEdge(0, 1);%0A        %0A        graph.addEdge(2, 0);%0A        graph.addEdge(2, 3);%0A        %0A        graph.addEdge(3, 5);%0A        graph.addEdge(3, 2);%0A        %0A        graph.addEdge(4, 3);%0A        graph.addEdge(4, 2);%0A        %0A        graph.addEdge(5, 4);%0A        %0A        graph.addEdge(6, 9);%0A        graph.addEdge(6, 4);%0A        graph.addEdge(6, 8);%0A        graph.addEdge(6, 0);%0A        %0A        graph.addEdge(7, 6);%0A        graph.addEdge(7, 9);%0A        %0A        graph.addEdge(8, 6);%0A        %0A        graph.addEdge(9, 11);%0A        graph.addEdge(9, 10);%0A        %0A        graph.addEdge(10, 12);%0A        %0A//        graph.addEdge(11, 4);%0A        graph.addEdge(11, 12);%0A        %0A        graph.addEdge(12, 9);%0A        %0A        Collection%3CInteger%3E reach = ReachabilityInGraph.reachable(graph, 12);%0A        Set%3CInteger%3E rReach = new HashSet%3C%3E();%0A        rReach.add(9);%0A        rReach.add(10);%0A        rReach.add(11);%0A        rReach.add(12);%0A        assertEquals(4, reach.size());%0A        for (Integer v : reach) %7B%0A            assertEquals(true, rReach.contains(v));%0A        %7D%0A    %7D%0A    %0A    public void testReachabilityInUndirectedGraph() %7B%0A        GraphAdjacencyListRepresentation graph = new GraphAdjacencyListRepresentation(13, false);%0A        graph.addEdge(0, 5);%0A        graph.addEdge(0, 1);%0A        %0A        graph.addEdge(2, 0);%0A        graph.addEdge(2, 3);%0A        %0A        graph.addEdge(3, 5);%0A        graph.addEdge(3, 2);%0A        %0A        graph.addEdge(4, 3);%0A        graph.addEdge(4, 2);%0A        %0A        graph.addEdge(5, 4);%0A        %0A        graph.addEdge(6, 4);%0A        graph.addEdge(6, 8);%0A        graph.addEdge(6, 0);%0A        %0A        graph.addEdge(7, 6);%0A        %0A        graph.addEdge(8, 6);%0A        %0A        graph.addEdge(9, 11);%0A        graph.addEdge(9, 10);%0A        %0A        graph.addEdge(10, 12);%0A        %0A        graph.addEdge(11, 12);%0A        %0A        graph.addEdge(12, 9);%0A        %0A        Collection%3CInteger%3E reach = ReachabilityInGraph.reachable(graph, 12);%0A        Set%3CInteger%3E rReach = new HashSet%3C%3E();%0A        rReach.add(9);%0A        rReach.add(10);%0A        rReach.add(11);%0A        rReach.add(12);%0A        assertEquals(4, reach.size());%0A        for (Integer v : reach) %7B%0A            assertEquals(true, rReach.contains(v));%0A        %7D%0A    %7D%0A    %0A%7D%0A

Add JUnit test for ReachabilityInGraph