From 8ebb66c356b2752e02389d02356a44076d47095e Mon Sep 17 00:00:00 2001 From: sam Date: Sun, 16 Oct 2016 23:20:07 -0500 Subject: [PATCH 01/10] removes weighted/directed flags from edge, updates graph to handle flags --- src/test/java/graphs/GraphSearchTest.java | 81 ++++++++++++----------- 1 file changed, 44 insertions(+), 37 deletions(-) diff --git a/src/test/java/graphs/GraphSearchTest.java b/src/test/java/graphs/GraphSearchTest.java index e6f7eb7..005e2e8 100644 --- a/src/test/java/graphs/GraphSearchTest.java +++ b/src/test/java/graphs/GraphSearchTest.java @@ -82,6 +82,7 @@ public void setUp() throws Exception { // A -> B -> C -> D -> E -> F // UndirectedUnweightedgraph1 = new GraphClass(nodesForUndirectedUnweightedGraph1, edgesForUndirectedUnweightedGraph1); + UndirectedUnweightedgraph1.setDirected(false); List nodesForUndirectedUnweightedGraph2 = new LinkedList(Arrays.asList( nodeA, @@ -118,6 +119,8 @@ public void setUp() throws Exception { // \------------> Z -------------/ // UndirectedUnweightedgraph2 = new GraphClass(nodesForUndirectedUnweightedGraph2, edgesForUndirectedUnweightedGraph2); + UndirectedUnweightedgraph2.setDirected(false); + // graph 2 has all nodes A - H & Z List nodesForUndirectedUnweightedGraph3 = nodesForUndirectedUnweightedGraph2; @@ -159,6 +162,8 @@ public void setUp() throws Exception { // Graph #3: see UndirectedUnweightedgraph3.png // UndirectedUnweightedgraph3 = new GraphClass(nodesForUndirectedUnweightedGraph3, edgesForUndirectedUnweightedGraph3); + UndirectedUnweightedgraph3.setDirected(false); + // graph 2 has all nodes A - H & Z List nodesForUndirectedUnweightedGraph4 = nodesForUndirectedUnweightedGraph2; @@ -201,7 +206,7 @@ public void setUp() throws Exception { // Graph #4: see UndirectedUnweightedgraph4.png // UndirectedUnweightedgraph4 = new GraphClass(nodesForUndirectedUnweightedGraph4, edgesForUndirectedUnweightedGraph4); - + UndirectedUnweightedgraph4.setDirected(false); // graph 2 has all nodes A - H & Z List nodesForUndirectedUnweightedGraph5 = nodesForUndirectedUnweightedGraph2; @@ -210,7 +215,7 @@ public void setUp() throws Exception { // // start and target have no path, will return empty list UndirectedUnweightedgraph5 = new GraphClass(nodesForUndirectedUnweightedGraph5, edgesForUndirectedUnweightedGraph1); - + UndirectedUnweightedgraph5.setDirected(false); // graph 2 has all nodes A - H & Z @@ -264,6 +269,8 @@ public void setUp() throws Exception { // Graph #6: graph with nodes from graph 1, fully connected // UndirectedUnweightedgraph6 = new GraphClass(nodesForUndirectedUnweightedGraph6, edgesForUndirectedUnweightedGraph6); + UndirectedUnweightedgraph6.setDirected(false); + // graph 2 has all nodes A - H & Z List nodesForUndirectedUnweightedGraph7 = nodesForUndirectedUnweightedGraph2; @@ -318,7 +325,7 @@ public void setUp() throws Exception { // Graph #7: graph7.png // UndirectedUnweightedgraph7 = new GraphClass(nodesForUndirectedUnweightedGraph7, edgesForUndirectedUnweightedGraph7); - + UndirectedUnweightedgraph7.setDirected(false); /* @@ -469,18 +476,18 @@ public void setUp() throws Exception { * */ List edgesForGraph11 = new LinkedList(); - edgesForGraph11.add(edgeBetweenAandD.setWeighted(true).setWeight(1)); - edgesForGraph11.add(edgeBetweenZandD.setWeighted(true).setWeight(2)); - edgesForGraph11.add(edgeBetweenBandD.setWeighted(true).setWeight(1)); - edgesForGraph11.add(edgeBetweenHandZ.setWeighted(true).setWeight(1)); - edgesForGraph11.add(edgeBetweenBandH.setWeighted(true).setWeight(1)); - edgesForGraph11.add(edgeBetweenCandE.setWeighted(true).setWeight(1)); - edgesForGraph11.add(edgeBetweenGandD.setWeighted(true).setWeight(1)); - edgesForGraph11.add(edgeBetweenZandG.setWeighted(true).setWeight(1)); - edgesForGraph11.add(edgeBetweenFandB.setWeighted(true).setWeight(1)); - edgesForGraph11.add(edgeBetweenDandC.setWeighted(true).setWeight(1)); - edgesForGraph11.add(edgeBetweenEandD.setWeighted(true).setWeight(1)); - edgesForGraph11.add(edgeBetweenDandF.setWeighted(true).setWeight(1)); + edgesForGraph11.add(edgeBetweenAandD.setWeight(1)); + edgesForGraph11.add(edgeBetweenZandD.setWeight(2)); + edgesForGraph11.add(edgeBetweenBandD.setWeight(1)); + edgesForGraph11.add(edgeBetweenHandZ.setWeight(1)); + edgesForGraph11.add(edgeBetweenBandH.setWeight(1)); + edgesForGraph11.add(edgeBetweenCandE.setWeight(1)); + edgesForGraph11.add(edgeBetweenGandD.setWeight(1)); + edgesForGraph11.add(edgeBetweenZandG.setWeight(1)); + edgesForGraph11.add(edgeBetweenFandB.setWeight(1)); + edgesForGraph11.add(edgeBetweenDandC.setWeight(1)); + edgesForGraph11.add(edgeBetweenEandD.setWeight(1)); + edgesForGraph11.add(edgeBetweenDandF.setWeight(1)); DirectedWeightedGraph11 = new GraphClass(nodesForUndirectedUnweightedGraph2, edgesForGraph11); DirectedWeightedGraph11.setDirected(true); DirectedWeightedGraph11.setWeighted(true); @@ -507,18 +514,18 @@ public void setUp() throws Exception { * */ List edgesForGraph12 = new LinkedList(); - edgesForGraph12.add(edgeBetweenAandB.setWeighted(true).setWeight(1)); - edgesForGraph12.add(edgeBetweenBandC.setWeighted(true).setWeight(1)); - edgesForGraph12.add(edgeBetweenCandE.setWeighted(true).setWeight(1)); - edgesForGraph12.add(edgeBetweenEandZ.setWeighted(true).setWeight(1)); - edgesForGraph12.add(edgeBetweenEandD.setWeighted(true).setWeight(2)); - edgesForGraph12.add(edgeBetweenGandD.setWeighted(true).setWeight(2)); - edgesForGraph12.add(edgeBetweenZandG.setWeighted(true).setWeight(1)); - edgesForGraph12.add(edgeBetweenHandZ.setWeighted(true).setWeight(1)); - edgesForGraph12.add(edgeBetweenFandH.setWeighted(true).setWeight(1)); - edgesForGraph12.add(edgeBetweenDandF.setWeighted(true).setWeight(1)); - edgesForGraph12.add(edgeBetweenGandA.setWeighted(true).setWeight(1)); - edgesForGraph12.add(edgeBetweenFandA.setWeighted(true).setWeight(1)); + edgesForGraph12.add(edgeBetweenAandB.setWeight(1)); + edgesForGraph12.add(edgeBetweenBandC.setWeight(1)); + edgesForGraph12.add(edgeBetweenCandE.setWeight(1)); + edgesForGraph12.add(edgeBetweenEandZ.setWeight(1)); + edgesForGraph12.add(edgeBetweenEandD.setWeight(2)); + edgesForGraph12.add(edgeBetweenGandD.setWeight(2)); + edgesForGraph12.add(edgeBetweenZandG.setWeight(1)); + edgesForGraph12.add(edgeBetweenHandZ.setWeight(1)); + edgesForGraph12.add(edgeBetweenFandH.setWeight(1)); + edgesForGraph12.add(edgeBetweenDandF.setWeight(1)); + edgesForGraph12.add(edgeBetweenGandA.setWeight(1)); + edgesForGraph12.add(edgeBetweenFandA.setWeight(1)); DirectedWeightedGraph12 = new GraphClass(nodesForUndirectedUnweightedGraph2, edgesForGraph12); DirectedWeightedGraph12.setDirected(true); DirectedWeightedGraph12.setWeighted(true); @@ -545,16 +552,16 @@ public void setUp() throws Exception { */ List edgesForGraph13 = new LinkedList(); - edgesForGraph13.add(edgeBetweenAandD.setWeighted(true).setWeight(1)); - edgesForGraph13.add(edgeBetweenAandC.setWeighted(true).setWeight(1)); - edgesForGraph13.add(edgeBetweenDandC.setWeighted(true).setWeight(1)); - edgesForGraph13.add(edgeBetweenBandF.setWeighted(true).setWeight(1)); - edgesForGraph13.add(edgeBetweenFandH.setWeighted(true).setWeight(1)); - edgesForGraph13.add(edgeBetweenZandC.setWeighted(true).setWeight(1)); - edgesForGraph13.add(edgeBetweenGandE.setWeighted(true).setWeight(2)); - edgesForGraph13.add(edgeBetweenEandB.setWeighted(true).setWeight(1)); - edgesForGraph13.add(edgeBetweenDandZ.setWeighted(true).setWeight(1)); - edgesForGraph13.add(edgeBetweenGandA.setWeighted(true).setWeight(1)); + edgesForGraph13.add(edgeBetweenAandD.setWeight(1)); + edgesForGraph13.add(edgeBetweenAandC.setWeight(1)); + edgesForGraph13.add(edgeBetweenDandC.setWeight(1)); + edgesForGraph13.add(edgeBetweenBandF.setWeight(1)); + edgesForGraph13.add(edgeBetweenFandH.setWeight(1)); + edgesForGraph13.add(edgeBetweenZandC.setWeight(1)); + edgesForGraph13.add(edgeBetweenGandE.setWeight(2)); + edgesForGraph13.add(edgeBetweenEandB.setWeight(1)); + edgesForGraph13.add(edgeBetweenDandZ.setWeight(1)); + edgesForGraph13.add(edgeBetweenGandA.setWeight(1)); DirectedWeightedGraph13 = new GraphClass(nodesForUndirectedUnweightedGraph2, edgesForGraph13); From 6aa66c57bb49bc52fbf9e41d51ad57c40bdee23b Mon Sep 17 00:00:00 2001 From: sam Date: Sun, 16 Oct 2016 23:20:24 -0500 Subject: [PATCH 02/10] removes weighted/directed flags from edge, updates graph to handle flags --- src/main/java/graphs/GraphClass.java | 16 ++++++++-- src/main/java/graphs/GraphEdge.java | 44 ++++------------------------ 2 files changed, 19 insertions(+), 41 deletions(-) diff --git a/src/main/java/graphs/GraphClass.java b/src/main/java/graphs/GraphClass.java index a3075a8..7a83855 100644 --- a/src/main/java/graphs/GraphClass.java +++ b/src/main/java/graphs/GraphClass.java @@ -43,6 +43,13 @@ public void addNode(GraphNode node) { public void addEdge(GraphEdge edge) { edges.add(edge); + if(! isDirected()) { + addUndirectedEdge(edge); + } + } + + private void addUndirectedEdge(GraphEdge edge) { + edges.add(new GraphEdge(edge.getRightNode(), edge.getLeftNode(), edge.getWeight())); } // public void addEdge(GraphNode leftNode, GraphNode rightNode) { @@ -71,8 +78,11 @@ public void removeEdge(GraphEdge edge) { // set directed will work on graph and all edges so can be done at the end public void setDirected(boolean directed) { isDirected = directed; - for(GraphEdge edge : edges) { - edge.setDirected(directed); + if (! isDirected) { + LinkedList currentEdges = new LinkedList(edges); + for(GraphEdge edge : currentEdges) { + addUndirectedEdge(edge); + } } } @@ -92,7 +102,7 @@ public void setWeighted(boolean weighted) { public List getIncidentEdges(GraphNode node) { List incidentEdges = new LinkedList(); for(GraphEdge edge : edges) { - if(edge.getLeftNode().equals(node) || (edge.getRightNode().equals(node) && ! isDirected)) { + if(edge.getLeftNode().equals(node)) { incidentEdges.add(edge); } } diff --git a/src/main/java/graphs/GraphEdge.java b/src/main/java/graphs/GraphEdge.java index 47004d7..eb9a43b 100644 --- a/src/main/java/graphs/GraphEdge.java +++ b/src/main/java/graphs/GraphEdge.java @@ -4,22 +4,17 @@ public class GraphEdge implements Comparable { private GraphNode leftNode; private GraphNode rightNode; private double weight; - private boolean isWeighted; - private boolean isDirected; public GraphEdge(GraphNode leftNode, GraphNode rightNode, double weight) { this.leftNode = leftNode; this.rightNode = rightNode; setWeight(weight); - setWeighted(true); - setDirected(false); } public GraphEdge(GraphNode leftNode, GraphNode rightNode) { this.leftNode = leftNode; this.rightNode = rightNode; - this.isWeighted = false; - setDirected(false); + setWeight(1); } public GraphEdge(GraphEdge edge) { @@ -29,38 +24,13 @@ public GraphEdge(GraphEdge edge) { } public double getWeight() { - if (!isWeighted) { - // i should throw an exception here? - } return weight; } - // the way this is written, taking an GraphEdge that is unweighted - // first need to setWeighted(true) then setWeight(weight) public GraphEdge setWeight(double weight) { - if (isWeighted) { - this.weight = weight; - } - return this; - } - - public boolean isWeighted() { - return isWeighted; - } - - public GraphEdge setWeighted(boolean weighted) { - this.isWeighted = weighted; return this; } - public boolean isDirected() { - return isDirected; - } - - public void setDirected(boolean directed) { - this.isDirected = directed; - } - public GraphNode getLeftNode() { return leftNode; } @@ -96,13 +66,11 @@ public GraphNode getOtherNode(GraphNode node) { // "Note: this class has a natural ordering that is inconsistent with equals." public int compareTo(GraphEdge edge) { - if (isWeighted && edge.isWeighted()) { - // is it necessary to specify "this." ? - if(edge.getWeight() > this.getWeight()) { - return -1; - } else if (this.getWeight() > edge.getWeight()){ - return 1; - } + // is it necessary to specify "this." ? + if(edge.getWeight() > this.getWeight()) { + return -1; + } else if (this.getWeight() > edge.getWeight()){ + return 1; } return 0; } From b5309c693fd16419f4bcf2c4e64d47f26105c930 Mon Sep 17 00:00:00 2001 From: sam Date: Mon, 17 Oct 2016 18:01:25 -0500 Subject: [PATCH 03/10] updates graph to be able to duplicate undirected edges, tests pass --- src/main/java/graphs/GraphClass.java | 19 ++++++++------- src/main/java/graphs/GraphEdge.java | 1 + src/test/java/graphs/GraphSearchTest.java | 28 +++++++++++------------ 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/main/java/graphs/GraphClass.java b/src/main/java/graphs/GraphClass.java index 7a83855..8f23ed0 100644 --- a/src/main/java/graphs/GraphClass.java +++ b/src/main/java/graphs/GraphClass.java @@ -44,14 +44,23 @@ public void addNode(GraphNode node) { public void addEdge(GraphEdge edge) { edges.add(edge); if(! isDirected()) { - addUndirectedEdge(edge); + duplicateAsUndirectedEdge(edge); } } - private void addUndirectedEdge(GraphEdge edge) { + private void duplicateAsUndirectedEdge(GraphEdge edge) { edges.add(new GraphEdge(edge.getRightNode(), edge.getLeftNode(), edge.getWeight())); } + public GraphClass duplicateUndirectedEdges() { + // since this method is public, "this" means the graph calling the method correct? + List edgesToCopy = new LinkedList(this.getEdges()); + for(GraphEdge edge : edgesToCopy) { + duplicateAsUndirectedEdge(edge); + } + return this; + } + // public void addEdge(GraphNode leftNode, GraphNode rightNode) { //// weight is the sqrt( ( left.x - right.x) ^ 2 + (left.y - right.y) ^ 2) // double weight = Math.sqrt(Math.pow(leftNode.getX() - rightNode.getX(), 2) + Math.pow((leftNode.getY() - rightNode.getY()),2)); @@ -78,12 +87,6 @@ public void removeEdge(GraphEdge edge) { // set directed will work on graph and all edges so can be done at the end public void setDirected(boolean directed) { isDirected = directed; - if (! isDirected) { - LinkedList currentEdges = new LinkedList(edges); - for(GraphEdge edge : currentEdges) { - addUndirectedEdge(edge); - } - } } public boolean isDirected() { diff --git a/src/main/java/graphs/GraphEdge.java b/src/main/java/graphs/GraphEdge.java index eb9a43b..bd3bd77 100644 --- a/src/main/java/graphs/GraphEdge.java +++ b/src/main/java/graphs/GraphEdge.java @@ -28,6 +28,7 @@ public double getWeight() { } public GraphEdge setWeight(double weight) { + this.weight = weight; return this; } diff --git a/src/test/java/graphs/GraphSearchTest.java b/src/test/java/graphs/GraphSearchTest.java index 005e2e8..295ecfd 100644 --- a/src/test/java/graphs/GraphSearchTest.java +++ b/src/test/java/graphs/GraphSearchTest.java @@ -82,7 +82,7 @@ public void setUp() throws Exception { // A -> B -> C -> D -> E -> F // UndirectedUnweightedgraph1 = new GraphClass(nodesForUndirectedUnweightedGraph1, edgesForUndirectedUnweightedGraph1); - UndirectedUnweightedgraph1.setDirected(false); + UndirectedUnweightedgraph1.duplicateUndirectedEdges(); List nodesForUndirectedUnweightedGraph2 = new LinkedList(Arrays.asList( nodeA, @@ -119,7 +119,7 @@ public void setUp() throws Exception { // \------------> Z -------------/ // UndirectedUnweightedgraph2 = new GraphClass(nodesForUndirectedUnweightedGraph2, edgesForUndirectedUnweightedGraph2); - UndirectedUnweightedgraph2.setDirected(false); + UndirectedUnweightedgraph2.duplicateUndirectedEdges(); // graph 2 has all nodes A - H & Z @@ -162,7 +162,7 @@ public void setUp() throws Exception { // Graph #3: see UndirectedUnweightedgraph3.png // UndirectedUnweightedgraph3 = new GraphClass(nodesForUndirectedUnweightedGraph3, edgesForUndirectedUnweightedGraph3); - UndirectedUnweightedgraph3.setDirected(false); + UndirectedUnweightedgraph3.duplicateUndirectedEdges(); // graph 2 has all nodes A - H & Z @@ -206,7 +206,7 @@ public void setUp() throws Exception { // Graph #4: see UndirectedUnweightedgraph4.png // UndirectedUnweightedgraph4 = new GraphClass(nodesForUndirectedUnweightedGraph4, edgesForUndirectedUnweightedGraph4); - UndirectedUnweightedgraph4.setDirected(false); + UndirectedUnweightedgraph4.duplicateUndirectedEdges(); // graph 2 has all nodes A - H & Z List nodesForUndirectedUnweightedGraph5 = nodesForUndirectedUnweightedGraph2; @@ -215,7 +215,7 @@ public void setUp() throws Exception { // // start and target have no path, will return empty list UndirectedUnweightedgraph5 = new GraphClass(nodesForUndirectedUnweightedGraph5, edgesForUndirectedUnweightedGraph1); - UndirectedUnweightedgraph5.setDirected(false); + UndirectedUnweightedgraph5.duplicateUndirectedEdges(); // graph 2 has all nodes A - H & Z @@ -269,7 +269,7 @@ public void setUp() throws Exception { // Graph #6: graph with nodes from graph 1, fully connected // UndirectedUnweightedgraph6 = new GraphClass(nodesForUndirectedUnweightedGraph6, edgesForUndirectedUnweightedGraph6); - UndirectedUnweightedgraph6.setDirected(false); + UndirectedUnweightedgraph6.duplicateUndirectedEdges(); // graph 2 has all nodes A - H & Z @@ -325,7 +325,7 @@ public void setUp() throws Exception { // Graph #7: graph7.png // UndirectedUnweightedgraph7 = new GraphClass(nodesForUndirectedUnweightedGraph7, edgesForUndirectedUnweightedGraph7); - UndirectedUnweightedgraph7.setDirected(false); + UndirectedUnweightedgraph7.duplicateUndirectedEdges(); /* @@ -686,27 +686,25 @@ public void breadthFirstSearchUndirectedUnweightedGraph03() throws Exception { @Test public void depthFirstSearchUndirectedUnweightedGraph04() throws Exception { List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph4, nodeB, nodeF); - Assert.assertEquals(path.size(), 7); + Assert.assertEquals(path.size(), 6); Assert.assertTrue(path.get(0).getValue().equals("B")); Assert.assertTrue(path.get(1).getValue().equals("E")); Assert.assertTrue(path.get(2).getValue().equals("G")); Assert.assertTrue(path.get(3).getValue().equals("H")); Assert.assertTrue(path.get(4).getValue().equals("D")); - Assert.assertTrue(path.get(5).getValue().equals("C")); - Assert.assertTrue(path.get(6).getValue().equals("F")); + Assert.assertTrue(path.get(5).getValue().equals("F")); } @Test public void depthFirstSearchRecursiveUndirectedUnweightedGraph04() throws Exception { List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph4, nodeB, nodeF); - Assert.assertEquals(path.size(), 7); + Assert.assertEquals(path.size(), 6); Assert.assertTrue(path.get(0).getValue().equals("B")); Assert.assertTrue(path.get(1).getValue().equals("E")); Assert.assertTrue(path.get(2).getValue().equals("G")); Assert.assertTrue(path.get(3).getValue().equals("H")); Assert.assertTrue(path.get(4).getValue().equals("D")); - Assert.assertTrue(path.get(5).getValue().equals("C")); - Assert.assertTrue(path.get(6).getValue().equals("F")); + Assert.assertTrue(path.get(5).getValue().equals("F")); } @Test @@ -760,13 +758,13 @@ public void breadthFirstSearchUndirectedUnweightedGraph06() throws Exception { @Test public void depthFirstSearchUndirectedUnweightedGraph07() throws Exception { List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph7, nodeA, nodeF); - Assert.assertEquals(path.size(), 6); + Assert.assertEquals(path.size(), 8); } @Test public void depthFirstSearchRecursiveUndirectedUnweightedGraph07() throws Exception { List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph7, nodeA, nodeF); - Assert.assertEquals(path.size(), 6); + Assert.assertEquals(path.size(), 8); } @Test From c359145c567b65b5d8c5168f8cf8515bee313426 Mon Sep 17 00:00:00 2001 From: sam Date: Wed, 19 Oct 2016 20:37:22 -0500 Subject: [PATCH 04/10] updates graph constructor and duplicating undirected edges --- src/main/java/graphs/GraphClass.java | 37 +++++++++--------- src/main/java/graphs/GraphSearch.java | 2 +- src/test/java/graphs/GraphSearchTest.java | 46 +++++++++++------------ 3 files changed, 40 insertions(+), 45 deletions(-) diff --git a/src/main/java/graphs/GraphClass.java b/src/main/java/graphs/GraphClass.java index 8f23ed0..df39b4b 100644 --- a/src/main/java/graphs/GraphClass.java +++ b/src/main/java/graphs/GraphClass.java @@ -16,9 +16,21 @@ public GraphClass() { } public GraphClass(List nodes, List edges) { - this.edges = edges; + // if no flag for isDirected, default false + this(nodes, edges, false); + } + + public GraphClass(List nodes, List edges, boolean isDirected) { this.nodes = nodes; - setDirected(false); + setDirected(isDirected); + if(isDirected()) { + this.edges = edges; + } else { + this.edges = new ArrayList(); + for(GraphEdge edge : edges) { + addEdge(edge); + } + } setWeighted(false); } @@ -44,24 +56,11 @@ public void addNode(GraphNode node) { public void addEdge(GraphEdge edge) { edges.add(edge); if(! isDirected()) { - duplicateAsUndirectedEdge(edge); - } - } - - private void duplicateAsUndirectedEdge(GraphEdge edge) { - edges.add(new GraphEdge(edge.getRightNode(), edge.getLeftNode(), edge.getWeight())); - } - - public GraphClass duplicateUndirectedEdges() { - // since this method is public, "this" means the graph calling the method correct? - List edgesToCopy = new LinkedList(this.getEdges()); - for(GraphEdge edge : edgesToCopy) { - duplicateAsUndirectedEdge(edge); + edges.add(new GraphEdge(edge.getRightNode(), edge.getLeftNode(), edge.getWeight())); } - return this; } -// public void addEdge(GraphNode leftNode, GraphNode rightNode) { + // public void addEdge(GraphNode leftNode, GraphNode rightNode) { //// weight is the sqrt( ( left.x - right.x) ^ 2 + (left.y - right.y) ^ 2) // double weight = Math.sqrt(Math.pow(leftNode.getX() - rightNode.getX(), 2) + Math.pow((leftNode.getY() - rightNode.getY()),2)); // edges.add(new GraphEdge(leftNode, rightNode, weight)); @@ -85,8 +84,8 @@ public void removeEdge(GraphEdge edge) { } // set directed will work on graph and all edges so can be done at the end - public void setDirected(boolean directed) { - isDirected = directed; + public void setDirected(boolean isDirected) { + this.isDirected = isDirected; } public boolean isDirected() { diff --git a/src/main/java/graphs/GraphSearch.java b/src/main/java/graphs/GraphSearch.java index 5414bf3..8c408b6 100644 --- a/src/main/java/graphs/GraphSearch.java +++ b/src/main/java/graphs/GraphSearch.java @@ -92,7 +92,7 @@ private static GraphNode getNextNode(List incidentEdges, Grap for (GraphEdge edge : incidentEdges) { GraphNode node = edge.getOtherNode(startingNode); if (!node.isVisited()) { - return edge.getOtherNode(startingNode); + return node; } } return null; diff --git a/src/test/java/graphs/GraphSearchTest.java b/src/test/java/graphs/GraphSearchTest.java index 295ecfd..34bf742 100644 --- a/src/test/java/graphs/GraphSearchTest.java +++ b/src/test/java/graphs/GraphSearchTest.java @@ -82,7 +82,7 @@ public void setUp() throws Exception { // A -> B -> C -> D -> E -> F // UndirectedUnweightedgraph1 = new GraphClass(nodesForUndirectedUnweightedGraph1, edgesForUndirectedUnweightedGraph1); - UndirectedUnweightedgraph1.duplicateUndirectedEdges(); + List nodesForUndirectedUnweightedGraph2 = new LinkedList(Arrays.asList( nodeA, @@ -119,7 +119,7 @@ public void setUp() throws Exception { // \------------> Z -------------/ // UndirectedUnweightedgraph2 = new GraphClass(nodesForUndirectedUnweightedGraph2, edgesForUndirectedUnweightedGraph2); - UndirectedUnweightedgraph2.duplicateUndirectedEdges(); + // graph 2 has all nodes A - H & Z @@ -162,7 +162,7 @@ public void setUp() throws Exception { // Graph #3: see UndirectedUnweightedgraph3.png // UndirectedUnweightedgraph3 = new GraphClass(nodesForUndirectedUnweightedGraph3, edgesForUndirectedUnweightedGraph3); - UndirectedUnweightedgraph3.duplicateUndirectedEdges(); + // graph 2 has all nodes A - H & Z @@ -206,7 +206,7 @@ public void setUp() throws Exception { // Graph #4: see UndirectedUnweightedgraph4.png // UndirectedUnweightedgraph4 = new GraphClass(nodesForUndirectedUnweightedGraph4, edgesForUndirectedUnweightedGraph4); - UndirectedUnweightedgraph4.duplicateUndirectedEdges(); + // graph 2 has all nodes A - H & Z List nodesForUndirectedUnweightedGraph5 = nodesForUndirectedUnweightedGraph2; @@ -215,7 +215,7 @@ public void setUp() throws Exception { // // start and target have no path, will return empty list UndirectedUnweightedgraph5 = new GraphClass(nodesForUndirectedUnweightedGraph5, edgesForUndirectedUnweightedGraph1); - UndirectedUnweightedgraph5.duplicateUndirectedEdges(); + // graph 2 has all nodes A - H & Z @@ -269,7 +269,7 @@ public void setUp() throws Exception { // Graph #6: graph with nodes from graph 1, fully connected // UndirectedUnweightedgraph6 = new GraphClass(nodesForUndirectedUnweightedGraph6, edgesForUndirectedUnweightedGraph6); - UndirectedUnweightedgraph6.duplicateUndirectedEdges(); + // graph 2 has all nodes A - H & Z @@ -325,7 +325,7 @@ public void setUp() throws Exception { // Graph #7: graph7.png // UndirectedUnweightedgraph7 = new GraphClass(nodesForUndirectedUnweightedGraph7, edgesForUndirectedUnweightedGraph7); - UndirectedUnweightedgraph7.duplicateUndirectedEdges(); + /* @@ -369,8 +369,7 @@ public void setUp() throws Exception { // use nodes from graph 2 - DirectedUnweightedGraph8 = new GraphClass(nodesForUndirectedUnweightedGraph2, edgesForGraph8); - DirectedUnweightedGraph8.setDirected(true); + DirectedUnweightedGraph8 = new GraphClass(nodesForUndirectedUnweightedGraph2, edgesForGraph8, true); // // Graph #8: directed and unweighted // @@ -412,8 +411,7 @@ public void setUp() throws Exception { edgesForGraph9.add(edgeBetweenFandA); - DirectedUnweightedGraph9 = new GraphClass(nodesForUndirectedUnweightedGraph2, edgesForGraph9); - DirectedUnweightedGraph9.setDirected(true); + DirectedUnweightedGraph9 = new GraphClass(nodesForUndirectedUnweightedGraph2, edgesForGraph9, true); // // Graph #9: directed and unweighted // @@ -450,8 +448,7 @@ public void setUp() throws Exception { edgesForGraph10.add(edgeBetweenDandZ); edgesForGraph10.add(edgeBetweenGandA); - DirectedUnweightedGraph10 = new GraphClass(nodesForUndirectedUnweightedGraph2, edgesForGraph10); - DirectedUnweightedGraph10.setDirected(true); + DirectedUnweightedGraph10 = new GraphClass(nodesForUndirectedUnweightedGraph2, edgesForGraph10, true); // // Graph #10: directed and unweighted // @@ -488,8 +485,7 @@ public void setUp() throws Exception { edgesForGraph11.add(edgeBetweenDandC.setWeight(1)); edgesForGraph11.add(edgeBetweenEandD.setWeight(1)); edgesForGraph11.add(edgeBetweenDandF.setWeight(1)); - DirectedWeightedGraph11 = new GraphClass(nodesForUndirectedUnweightedGraph2, edgesForGraph11); - DirectedWeightedGraph11.setDirected(true); + DirectedWeightedGraph11 = new GraphClass(nodesForUndirectedUnweightedGraph2, edgesForGraph11, true); DirectedWeightedGraph11.setWeighted(true); // @@ -526,8 +522,7 @@ public void setUp() throws Exception { edgesForGraph12.add(edgeBetweenDandF.setWeight(1)); edgesForGraph12.add(edgeBetweenGandA.setWeight(1)); edgesForGraph12.add(edgeBetweenFandA.setWeight(1)); - DirectedWeightedGraph12 = new GraphClass(nodesForUndirectedUnweightedGraph2, edgesForGraph12); - DirectedWeightedGraph12.setDirected(true); + DirectedWeightedGraph12 = new GraphClass(nodesForUndirectedUnweightedGraph2, edgesForGraph12, true); DirectedWeightedGraph12.setWeighted(true); // @@ -564,8 +559,7 @@ public void setUp() throws Exception { edgesForGraph13.add(edgeBetweenGandA.setWeight(1)); - DirectedWeightedGraph13 = new GraphClass(nodesForUndirectedUnweightedGraph2, edgesForGraph13); - DirectedWeightedGraph13.setDirected(true); + DirectedWeightedGraph13 = new GraphClass(nodesForUndirectedUnweightedGraph2, edgesForGraph13, true); DirectedWeightedGraph13.setWeighted(true); // @@ -686,25 +680,27 @@ public void breadthFirstSearchUndirectedUnweightedGraph03() throws Exception { @Test public void depthFirstSearchUndirectedUnweightedGraph04() throws Exception { List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph4, nodeB, nodeF); - Assert.assertEquals(path.size(), 6); + Assert.assertEquals(path.size(), 7); Assert.assertTrue(path.get(0).getValue().equals("B")); Assert.assertTrue(path.get(1).getValue().equals("E")); Assert.assertTrue(path.get(2).getValue().equals("G")); Assert.assertTrue(path.get(3).getValue().equals("H")); Assert.assertTrue(path.get(4).getValue().equals("D")); - Assert.assertTrue(path.get(5).getValue().equals("F")); + Assert.assertTrue(path.get(5).getValue().equals("C")); + Assert.assertTrue(path.get(6).getValue().equals("F")); } @Test public void depthFirstSearchRecursiveUndirectedUnweightedGraph04() throws Exception { List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph4, nodeB, nodeF); - Assert.assertEquals(path.size(), 6); + Assert.assertEquals(path.size(), 7); Assert.assertTrue(path.get(0).getValue().equals("B")); Assert.assertTrue(path.get(1).getValue().equals("E")); Assert.assertTrue(path.get(2).getValue().equals("G")); Assert.assertTrue(path.get(3).getValue().equals("H")); Assert.assertTrue(path.get(4).getValue().equals("D")); - Assert.assertTrue(path.get(5).getValue().equals("F")); + Assert.assertTrue(path.get(5).getValue().equals("C")); + Assert.assertTrue(path.get(6).getValue().equals("F")); } @Test @@ -758,13 +754,13 @@ public void breadthFirstSearchUndirectedUnweightedGraph06() throws Exception { @Test public void depthFirstSearchUndirectedUnweightedGraph07() throws Exception { List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph7, nodeA, nodeF); - Assert.assertEquals(path.size(), 8); + Assert.assertEquals(path.size(), 6); } @Test public void depthFirstSearchRecursiveUndirectedUnweightedGraph07() throws Exception { List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph7, nodeA, nodeF); - Assert.assertEquals(path.size(), 8); + Assert.assertEquals(path.size(), 6); } @Test From 49a60acb492d7fe71a7f0f359ae83a894a9a37ef Mon Sep 17 00:00:00 2001 From: sam Date: Wed, 19 Oct 2016 22:05:17 -0500 Subject: [PATCH 05/10] renames classes --- .../java/graphs/{GraphEdge.java => Edge.java} | 28 +- .../graphs/{GraphClass.java => Graph.java} | 50 +-- src/main/java/graphs/GraphSearch.java | 68 ++-- .../java/graphs/{GraphNode.java => Node.java} | 8 +- src/test/java/graphs/GraphSearchTest.java | 310 +++++++++--------- 5 files changed, 232 insertions(+), 232 deletions(-) rename src/main/java/graphs/{GraphEdge.java => Edge.java} (67%) rename src/main/java/graphs/{GraphClass.java => Graph.java} (62%) rename src/main/java/graphs/{GraphNode.java => Node.java} (84%) diff --git a/src/main/java/graphs/GraphEdge.java b/src/main/java/graphs/Edge.java similarity index 67% rename from src/main/java/graphs/GraphEdge.java rename to src/main/java/graphs/Edge.java index bd3bd77..af54f03 100644 --- a/src/main/java/graphs/GraphEdge.java +++ b/src/main/java/graphs/Edge.java @@ -1,23 +1,23 @@ package graphs; -public class GraphEdge implements Comparable { - private GraphNode leftNode; - private GraphNode rightNode; +public class Edge implements Comparable { + private Node leftNode; + private Node rightNode; private double weight; - public GraphEdge(GraphNode leftNode, GraphNode rightNode, double weight) { + public Edge(Node leftNode, Node rightNode, double weight) { this.leftNode = leftNode; this.rightNode = rightNode; setWeight(weight); } - public GraphEdge(GraphNode leftNode, GraphNode rightNode) { + public Edge(Node leftNode, Node rightNode) { this.leftNode = leftNode; this.rightNode = rightNode; setWeight(1); } - public GraphEdge(GraphEdge edge) { + public Edge(Edge edge) { this.leftNode = edge.getLeftNode(); this.rightNode = edge.getRightNode(); this.weight = edge.getWeight(); @@ -27,33 +27,33 @@ public double getWeight() { return weight; } - public GraphEdge setWeight(double weight) { + public Edge setWeight(double weight) { this.weight = weight; return this; } - public GraphNode getLeftNode() { + public Node getLeftNode() { return leftNode; } - public GraphNode getRightNode() { + public Node getRightNode() { return rightNode; } - public void setLeftNode(GraphNode leftNode) { + public void setLeftNode(Node leftNode) { this.leftNode = leftNode; } - public void setRightNode(GraphNode rightNode) { + public void setRightNode(Node rightNode) { this.rightNode = rightNode; } - public boolean contains(GraphNode node) { + public boolean contains(Node node) { return leftNode.equals(node) || rightNode.equals(node); } // will return null if node is not in edge, else returns opposite node - public GraphNode getOtherNode(GraphNode node) { + public Node getOtherNode(Node node) { if(contains(node)) { if(node.equals(getRightNode())) { return getLeftNode(); @@ -66,7 +66,7 @@ public GraphNode getOtherNode(GraphNode node) { } // "Note: this class has a natural ordering that is inconsistent with equals." - public int compareTo(GraphEdge edge) { + public int compareTo(Edge edge) { // is it necessary to specify "this." ? if(edge.getWeight() > this.getWeight()) { return -1; diff --git a/src/main/java/graphs/GraphClass.java b/src/main/java/graphs/Graph.java similarity index 62% rename from src/main/java/graphs/GraphClass.java rename to src/main/java/graphs/Graph.java index df39b4b..2e41ed5 100644 --- a/src/main/java/graphs/GraphClass.java +++ b/src/main/java/graphs/Graph.java @@ -2,74 +2,74 @@ import java.util.*; -public class GraphClass { - private List edges; - private List nodes; +public class Graph { + private List edges; + private List nodes; private boolean isDirected; private boolean isWeighted; - public GraphClass() { - edges = new ArrayList(); - nodes = new ArrayList(); + public Graph() { + edges = new ArrayList(); + nodes = new ArrayList(); setDirected(false); setWeighted(false); } - public GraphClass(List nodes, List edges) { + public Graph(List nodes, List edges) { // if no flag for isDirected, default false this(nodes, edges, false); } - public GraphClass(List nodes, List edges, boolean isDirected) { + public Graph(List nodes, List edges, boolean isDirected) { this.nodes = nodes; setDirected(isDirected); if(isDirected()) { this.edges = edges; } else { - this.edges = new ArrayList(); - for(GraphEdge edge : edges) { + this.edges = new ArrayList(); + for(Edge edge : edges) { addEdge(edge); } } setWeighted(false); } - public GraphClass(GraphClass graph) { + public Graph(Graph graph) { edges = graph.getEdges(); nodes = graph.getNodes(); isDirected = graph.isDirected(); isWeighted = graph.isWeighted(); } - public List getEdges() { + public List getEdges() { return edges; } - public List getNodes() { + public List getNodes() { return nodes; } - public void addNode(GraphNode node) { + public void addNode(Node node) { nodes.add(node); } - public void addEdge(GraphEdge edge) { + public void addEdge(Edge edge) { edges.add(edge); if(! isDirected()) { - edges.add(new GraphEdge(edge.getRightNode(), edge.getLeftNode(), edge.getWeight())); + edges.add(new Edge(edge.getRightNode(), edge.getLeftNode(), edge.getWeight())); } } - // public void addEdge(GraphNode leftNode, GraphNode rightNode) { + // public void addEdge(Node leftNode, Node rightNode) { //// weight is the sqrt( ( left.x - right.x) ^ 2 + (left.y - right.y) ^ 2) // double weight = Math.sqrt(Math.pow(leftNode.getX() - rightNode.getX(), 2) + Math.pow((leftNode.getY() - rightNode.getY()),2)); -// edges.add(new GraphEdge(leftNode, rightNode, weight)); +// edges.add(new Edge(leftNode, rightNode, weight)); // } // returns removed node for chaining - public GraphNode removeNode(GraphNode node) { - Set toRemove = new HashSet(); - for(GraphEdge edge : edges) { + public Node removeNode(Node node) { + Set toRemove = new HashSet(); + for(Edge edge : edges) { if(edge.contains(node)) { toRemove.add(edge); } @@ -79,7 +79,7 @@ public GraphNode removeNode(GraphNode node) { return node; } - public void removeEdge(GraphEdge edge) { + public void removeEdge(Edge edge) { edges.remove(edge); } @@ -101,9 +101,9 @@ public void setWeighted(boolean weighted) { isWeighted = weighted; } - public List getIncidentEdges(GraphNode node) { - List incidentEdges = new LinkedList(); - for(GraphEdge edge : edges) { + public List getIncidentEdges(Node node) { + List incidentEdges = new LinkedList(); + for(Edge edge : edges) { if(edge.getLeftNode().equals(node)) { incidentEdges.add(edge); } diff --git a/src/main/java/graphs/GraphSearch.java b/src/main/java/graphs/GraphSearch.java index 8c408b6..246d2b5 100644 --- a/src/main/java/graphs/GraphSearch.java +++ b/src/main/java/graphs/GraphSearch.java @@ -4,7 +4,7 @@ public class GraphSearch { - public static List depthFirstSearch(GraphClass graph, GraphNode start, GraphNode finish) { + public static List depthFirstSearch(Graph graph, Node start, Node finish) { if (graph == null || graph.isEmpty()) { throw new IllegalArgumentException("empty or null graph"); @@ -13,21 +13,21 @@ public static List depthFirstSearch(GraphClass graph, GraphNode start throw new IllegalArgumentException("null start node or target node"); } if(! (graph.getNodes().contains(start) && graph.getNodes().contains(finish))) { - return new LinkedList(); + return new LinkedList(); } // DFS uses a stack of nodes visited // stack is push pop peek : peek to see - Stack location = new Stack(); + Stack location = new Stack(); start.visit(); location.push(start); boolean searching = true; while (searching) { - GraphNode currentNode = location.peek(); - List incidentEdges = graph.getIncidentEdges(currentNode); + Node currentNode = location.peek(); + List incidentEdges = graph.getIncidentEdges(currentNode); // getNextNode can return null - GraphNode nextNode = getNextNode(incidentEdges, currentNode); + Node nextNode = getNextNode(incidentEdges, currentNode); if(nextNode == null) { location.pop(); if (location.isEmpty()) { @@ -35,16 +35,16 @@ public static List depthFirstSearch(GraphClass graph, GraphNode start } } else if (nextNode.equals(finish)) { location.push(nextNode); - return new LinkedList(location); + return new LinkedList(location); } else { nextNode.visit(); location.push(nextNode); } } - return new LinkedList(); + return new LinkedList(); } - public static List depthFirstSearchRecursive(GraphClass graph, GraphNode start, GraphNode finish) { + public static List depthFirstSearchRecursive(Graph graph, Node start, Node finish) { if (graph == null || graph.isEmpty()) { throw new IllegalArgumentException("empty or null graph"); } @@ -52,32 +52,32 @@ public static List depthFirstSearchRecursive(GraphClass graph, GraphN throw new IllegalArgumentException("null start node or target node"); } if(! (graph.getNodes().contains(start) && graph.getNodes().contains(finish))) { - return new LinkedList(); + return new LinkedList(); } // DFS uses a stack of nodes visited // stack is push pop peek : peek to see - Stack location = new Stack(); + Stack location = new Stack(); start.visit(); location.push(start); return depthFirstSearchRecursive(graph, start, finish, location); } - public static List depthFirstSearchRecursive(GraphClass graph, GraphNode start, GraphNode finish, Stack location) { + public static List depthFirstSearchRecursive(Graph graph, Node start, Node finish, Stack location) { - GraphNode currentNode = location.peek(); - List incidentEdges = graph.getIncidentEdges(currentNode); + Node currentNode = location.peek(); + List incidentEdges = graph.getIncidentEdges(currentNode); // getNextNode can return null - GraphNode nextNode = getNextNode(incidentEdges, currentNode); + Node nextNode = getNextNode(incidentEdges, currentNode); if (nextNode == null) { location.pop(); if (location.isEmpty()) { // if search has not found finish, because stack has been filled and emptied - return new LinkedList(); + return new LinkedList(); } } else if (nextNode.equals(finish)) { location.push(nextNode); - return new LinkedList(location); + return new LinkedList(location); } else { nextNode.visit(); location.push(nextNode); @@ -85,12 +85,12 @@ public static List depthFirstSearchRecursive(GraphClass graph, GraphN return depthFirstSearchRecursive(graph, start, finish, location); } - private static GraphNode getNextNode(List incidentEdges, GraphNode startingNode) { + private static Node getNextNode(List incidentEdges, Node startingNode) { if (incidentEdges.isEmpty() || incidentEdges == null || startingNode == null) { return null; } else { - for (GraphEdge edge : incidentEdges) { - GraphNode node = edge.getOtherNode(startingNode); + for (Edge edge : incidentEdges) { + Node node = edge.getOtherNode(startingNode); if (!node.isVisited()) { return node; } @@ -99,7 +99,7 @@ private static GraphNode getNextNode(List incidentEdges, Grap } } - public static List breadthFirstSearch(GraphClass graph, GraphNode start, GraphNode finish) { + public static List breadthFirstSearch(Graph graph, Node start, Node finish) { if (graph == null || graph.isEmpty()) { throw new IllegalArgumentException("empty or null graph"); } @@ -107,26 +107,26 @@ public static List breadthFirstSearch(GraphClass graph, GraphNode st throw new IllegalArgumentException("null start node or target node"); } if(! (graph.getNodes().contains(start) && graph.getNodes().contains(finish))) { - return new LinkedList(); + return new LinkedList(); } // BFS uses a queue of nodes to visit // queue is add poll to get and remove peek to see - Queue nodeQueue = new LinkedList(); + Queue nodeQueue = new LinkedList(); start.visit(); nodeQueue.add(start); // list of nodes in order to be returned - LinkedList transitions = new LinkedList(); + LinkedList transitions = new LinkedList(); - GraphNode currentNode = nodeQueue.poll(); + Node currentNode = nodeQueue.poll(); double distance = 0; while (currentNode != null) { - List incidentEdges = graph.getIncidentEdges(currentNode); + List incidentEdges = graph.getIncidentEdges(currentNode); // getNextNode can return null - GraphNode nextNode = getNextNode(incidentEdges, currentNode); + Node nextNode = getNextNode(incidentEdges, currentNode); while (nextNode != null) { - transitions.add(new GraphEdge(currentNode, nextNode)); + transitions.add(new Edge(currentNode, nextNode)); if(nextNode.equals(finish)) { return getPathHome(transitions, start, finish); } else { @@ -138,18 +138,18 @@ public static List breadthFirstSearch(GraphClass graph, GraphNode st currentNode = nodeQueue.poll(); } // if target was never found, return empty list - return new LinkedList(); + return new LinkedList(); } // start node is unused, as this helper assumes the front of transitions is start - private static List getPathHome(List transitions, GraphNode start, GraphNode finish) { - GraphNode to = finish; - GraphNode from; - LinkedList nodeList = new LinkedList(); + private static List getPathHome(List transitions, Node start, Node finish) { + Node to = finish; + Node from; + LinkedList nodeList = new LinkedList(); nodeList.addFirst(to); while(! transitions.isEmpty()) { - GraphEdge edge = transitions.remove(transitions.size() - 1); + Edge edge = transitions.remove(transitions.size() - 1); if(edge.getRightNode().equals(to)) { from = edge.getLeftNode(); nodeList.addFirst(from); diff --git a/src/main/java/graphs/GraphNode.java b/src/main/java/graphs/Node.java similarity index 84% rename from src/main/java/graphs/GraphNode.java rename to src/main/java/graphs/Node.java index 323462a..a313602 100644 --- a/src/main/java/graphs/GraphNode.java +++ b/src/main/java/graphs/Node.java @@ -1,25 +1,25 @@ package graphs; -public class GraphNode { +public class Node { private float x; private float y; private T value; private boolean visited; - public GraphNode(GraphNode node) { + public Node(Node node) { setX(node.getX()); setY(node.getY()); setValue(node.getValue()); } - public GraphNode(float x, float y, T value) { + public Node(float x, float y, T value) { this.x = x; this.y = y; this.value = value; } - public GraphNode(T value) { + public Node(T value) { this.value = value; } diff --git a/src/test/java/graphs/GraphSearchTest.java b/src/test/java/graphs/GraphSearchTest.java index 34bf742..cd52b65 100644 --- a/src/test/java/graphs/GraphSearchTest.java +++ b/src/test/java/graphs/GraphSearchTest.java @@ -15,17 +15,17 @@ */ public class GraphSearchTest { - private GraphNode nodeA; - private GraphNode nodeB; - private GraphNode nodeC; - private GraphNode nodeD; - private GraphNode nodeE; - private GraphNode nodeF; - private GraphNode nodeG; - private GraphNode nodeH; - private GraphNode nodeZ; - - private GraphClass UndirectedUnweightedgraph1, + private Node nodeA; + private Node nodeB; + private Node nodeC; + private Node nodeD; + private Node nodeE; + private Node nodeF; + private Node nodeG; + private Node nodeH; + private Node nodeZ; + + private Graph UndirectedUnweightedgraph1, UndirectedUnweightedgraph2, UndirectedUnweightedgraph3, UndirectedUnweightedgraph4, @@ -46,17 +46,17 @@ public class GraphSearchTest { @Before public void setUp() throws Exception { - nodeA = new GraphNode("A"); - nodeB = new GraphNode("B"); - nodeC = new GraphNode("C"); - nodeD = new GraphNode("D"); - nodeE = new GraphNode("E"); - nodeF = new GraphNode("F"); - nodeG = new GraphNode("G"); - nodeH = new GraphNode("H"); - nodeZ = new GraphNode("Z"); - - List nodesForUndirectedUnweightedGraph1 = new LinkedList(Arrays.asList( + nodeA = new Node("A"); + nodeB = new Node("B"); + nodeC = new Node("C"); + nodeD = new Node("D"); + nodeE = new Node("E"); + nodeF = new Node("F"); + nodeG = new Node("G"); + nodeH = new Node("H"); + nodeZ = new Node("Z"); + + List nodesForUndirectedUnweightedGraph1 = new LinkedList(Arrays.asList( nodeA, nodeB, nodeC, @@ -65,13 +65,13 @@ public void setUp() throws Exception { nodeF )); - GraphEdge edgeBetweenAandB = new GraphEdge(nodeA, nodeB); - GraphEdge edgeBetweenBandC = new GraphEdge(nodeB, nodeC); - GraphEdge edgeBetweenCandD = new GraphEdge(nodeC, nodeD); - GraphEdge edgeBetweenDandE = new GraphEdge(nodeD, nodeE); - GraphEdge edgeBetweenEandF = new GraphEdge(nodeE, nodeF); + Edge edgeBetweenAandB = new Edge(nodeA, nodeB); + Edge edgeBetweenBandC = new Edge(nodeB, nodeC); + Edge edgeBetweenCandD = new Edge(nodeC, nodeD); + Edge edgeBetweenDandE = new Edge(nodeD, nodeE); + Edge edgeBetweenEandF = new Edge(nodeE, nodeF); - List edgesForUndirectedUnweightedGraph1 = new LinkedList(); + List edgesForUndirectedUnweightedGraph1 = new LinkedList(); edgesForUndirectedUnweightedGraph1.add(edgeBetweenAandB); edgesForUndirectedUnweightedGraph1.add(edgeBetweenBandC); edgesForUndirectedUnweightedGraph1.add(edgeBetweenCandD); @@ -81,10 +81,10 @@ public void setUp() throws Exception { // Graph #1: Straight line (unweighted, undirected) // A -> B -> C -> D -> E -> F // - UndirectedUnweightedgraph1 = new GraphClass(nodesForUndirectedUnweightedGraph1, edgesForUndirectedUnweightedGraph1); + UndirectedUnweightedgraph1 = new Graph(nodesForUndirectedUnweightedGraph1, edgesForUndirectedUnweightedGraph1); - List nodesForUndirectedUnweightedGraph2 = new LinkedList(Arrays.asList( + List nodesForUndirectedUnweightedGraph2 = new LinkedList(Arrays.asList( nodeA, nodeB, nodeC, @@ -96,12 +96,12 @@ public void setUp() throws Exception { nodeZ )); - GraphEdge edgeBetweenFandG = new GraphEdge(nodeF, nodeG); - GraphEdge edgeBetweenGandH = new GraphEdge(nodeG, nodeH); - GraphEdge edgeBetweenAandZ = new GraphEdge(nodeA, nodeZ); - GraphEdge edgeBetweenHandZ = new GraphEdge(nodeH, nodeZ); + Edge edgeBetweenFandG = new Edge(nodeF, nodeG); + Edge edgeBetweenGandH = new Edge(nodeG, nodeH); + Edge edgeBetweenAandZ = new Edge(nodeA, nodeZ); + Edge edgeBetweenHandZ = new Edge(nodeH, nodeZ); - List edgesForUndirectedUnweightedGraph2 = new LinkedList(); + List edgesForUndirectedUnweightedGraph2 = new LinkedList(); edgesForUndirectedUnweightedGraph2.add(edgeBetweenAandB); edgesForUndirectedUnweightedGraph2.add(edgeBetweenBandC); edgesForUndirectedUnweightedGraph2.add(edgeBetweenCandD); @@ -118,14 +118,14 @@ public void setUp() throws Exception { // \ / // \------------> Z -------------/ // - UndirectedUnweightedgraph2 = new GraphClass(nodesForUndirectedUnweightedGraph2, edgesForUndirectedUnweightedGraph2); + UndirectedUnweightedgraph2 = new Graph(nodesForUndirectedUnweightedGraph2, edgesForUndirectedUnweightedGraph2); // graph 2 has all nodes A - H & Z - List nodesForUndirectedUnweightedGraph3 = nodesForUndirectedUnweightedGraph2; + List nodesForUndirectedUnweightedGraph3 = nodesForUndirectedUnweightedGraph2; -// GraphEdge edgeBetweenHandZ = new GraphEdge(nodeZ, nodeH); +// Edge edgeBetweenHandZ = new Edge(nodeZ, nodeH); /* * make edges, then make edge list: * graph 3 has edges: @@ -140,14 +140,14 @@ public void setUp() throws Exception { * E - G */ - GraphEdge edgeBetweenEandZ = new GraphEdge(nodeE, nodeZ); - GraphEdge edgeBetweenEandG = new GraphEdge(nodeE, nodeG); - GraphEdge edgeBetweenDandH = new GraphEdge(nodeD, nodeH); - GraphEdge edgeBetweenDandF = new GraphEdge(nodeD, nodeF); - GraphEdge edgeBetweenBandD = new GraphEdge(nodeB, nodeD); - GraphEdge edgeBetweenAandD = new GraphEdge(nodeA, nodeD); + Edge edgeBetweenEandZ = new Edge(nodeE, nodeZ); + Edge edgeBetweenEandG = new Edge(nodeE, nodeG); + Edge edgeBetweenDandH = new Edge(nodeD, nodeH); + Edge edgeBetweenDandF = new Edge(nodeD, nodeF); + Edge edgeBetweenBandD = new Edge(nodeB, nodeD); + Edge edgeBetweenAandD = new Edge(nodeA, nodeD); - List edgesForUndirectedUnweightedGraph3 = new LinkedList(); + List edgesForUndirectedUnweightedGraph3 = new LinkedList(); edgesForUndirectedUnweightedGraph3.add(edgeBetweenBandC); edgesForUndirectedUnweightedGraph3.add(edgeBetweenCandD); edgesForUndirectedUnweightedGraph3.add(edgeBetweenHandZ); @@ -161,14 +161,14 @@ public void setUp() throws Exception { // // Graph #3: see UndirectedUnweightedgraph3.png // - UndirectedUnweightedgraph3 = new GraphClass(nodesForUndirectedUnweightedGraph3, edgesForUndirectedUnweightedGraph3); + UndirectedUnweightedgraph3 = new Graph(nodesForUndirectedUnweightedGraph3, edgesForUndirectedUnweightedGraph3); // graph 2 has all nodes A - H & Z - List nodesForUndirectedUnweightedGraph4 = nodesForUndirectedUnweightedGraph2; + List nodesForUndirectedUnweightedGraph4 = nodesForUndirectedUnweightedGraph2; -// GraphEdge edgeBetweenHandZ = new GraphEdge(nodeZ, nodeH); +// Edge edgeBetweenHandZ = new Edge(nodeZ, nodeH); /* * make edges, then make edge list: * graph 4 has edges: @@ -184,12 +184,12 @@ public void setUp() throws Exception { * c-f * */ - GraphEdge edgeBetweenBandE = new GraphEdge(nodeB, nodeE); - GraphEdge edgeBetweenBandH = new GraphEdge(nodeB, nodeH); - GraphEdge edgeBetweenCandF = new GraphEdge(nodeC, nodeF); + Edge edgeBetweenBandE = new Edge(nodeB, nodeE); + Edge edgeBetweenBandH = new Edge(nodeB, nodeH); + Edge edgeBetweenCandF = new Edge(nodeC, nodeF); - List edgesForUndirectedUnweightedGraph4 = new LinkedList(); + List edgesForUndirectedUnweightedGraph4 = new LinkedList(); edgesForUndirectedUnweightedGraph4.add(edgeBetweenCandD); edgesForUndirectedUnweightedGraph4.add(edgeBetweenHandZ); edgesForUndirectedUnweightedGraph4.add(edgeBetweenEandG); @@ -205,21 +205,21 @@ public void setUp() throws Exception { // // Graph #4: see UndirectedUnweightedgraph4.png // - UndirectedUnweightedgraph4 = new GraphClass(nodesForUndirectedUnweightedGraph4, edgesForUndirectedUnweightedGraph4); + UndirectedUnweightedgraph4 = new Graph(nodesForUndirectedUnweightedGraph4, edgesForUndirectedUnweightedGraph4); // graph 2 has all nodes A - H & Z - List nodesForUndirectedUnweightedGraph5 = nodesForUndirectedUnweightedGraph2; + List nodesForUndirectedUnweightedGraph5 = nodesForUndirectedUnweightedGraph2; // // Graph #5: graph with nodes from graph 2 and edges from graph 1 // // start and target have no path, will return empty list - UndirectedUnweightedgraph5 = new GraphClass(nodesForUndirectedUnweightedGraph5, edgesForUndirectedUnweightedGraph1); + UndirectedUnweightedgraph5 = new Graph(nodesForUndirectedUnweightedGraph5, edgesForUndirectedUnweightedGraph1); // graph 2 has all nodes A - H & Z - List nodesForUndirectedUnweightedGraph6 = nodesForUndirectedUnweightedGraph2; + List nodesForUndirectedUnweightedGraph6 = nodesForUndirectedUnweightedGraph2; /* * make edges, then make edge list: * graph 6 nodes A-F, and all edges (15) @@ -241,14 +241,14 @@ public void setUp() throws Exception { * */ - GraphEdge edgeBetweenCandE = new GraphEdge(nodeC, nodeE); - GraphEdge edgeBetweenBandF = new GraphEdge(nodeB, nodeF); - GraphEdge edgeBetweenAandF = new GraphEdge(nodeA, nodeF); - GraphEdge edgeBetweenAandE = new GraphEdge(nodeA, nodeE); - GraphEdge edgeBetweenAandC = new GraphEdge(nodeA, nodeC); + Edge edgeBetweenCandE = new Edge(nodeC, nodeE); + Edge edgeBetweenBandF = new Edge(nodeB, nodeF); + Edge edgeBetweenAandF = new Edge(nodeA, nodeF); + Edge edgeBetweenAandE = new Edge(nodeA, nodeE); + Edge edgeBetweenAandC = new Edge(nodeA, nodeC); - List edgesForUndirectedUnweightedGraph6 = new LinkedList(edgesForUndirectedUnweightedGraph1); + List edgesForUndirectedUnweightedGraph6 = new LinkedList(edgesForUndirectedUnweightedGraph1); edgesForUndirectedUnweightedGraph6.add(edgeBetweenCandF); edgesForUndirectedUnweightedGraph6.add(edgeBetweenAandB); edgesForUndirectedUnweightedGraph6.add(edgeBetweenAandD); @@ -268,12 +268,12 @@ public void setUp() throws Exception { // // Graph #6: graph with nodes from graph 1, fully connected // - UndirectedUnweightedgraph6 = new GraphClass(nodesForUndirectedUnweightedGraph6, edgesForUndirectedUnweightedGraph6); + UndirectedUnweightedgraph6 = new Graph(nodesForUndirectedUnweightedGraph6, edgesForUndirectedUnweightedGraph6); // graph 2 has all nodes A - H & Z - List nodesForUndirectedUnweightedGraph7 = nodesForUndirectedUnweightedGraph2; + List nodesForUndirectedUnweightedGraph7 = nodesForUndirectedUnweightedGraph2; // edges needed (17): /* * a-b ~ @@ -297,13 +297,13 @@ public void setUp() throws Exception { */ - GraphEdge edgeBetweenCandH = new GraphEdge(nodeC, nodeH); - GraphEdge edgeBetweenBandG = new GraphEdge(nodeB, nodeG); - GraphEdge edgeBetweenAandG = new GraphEdge(nodeA, nodeG); - GraphEdge edgeBetweenGandZ = new GraphEdge(nodeG, nodeZ); - GraphEdge edgeBetweenFandH = new GraphEdge(nodeF, nodeH); + Edge edgeBetweenCandH = new Edge(nodeC, nodeH); + Edge edgeBetweenBandG = new Edge(nodeB, nodeG); + Edge edgeBetweenAandG = new Edge(nodeA, nodeG); + Edge edgeBetweenGandZ = new Edge(nodeG, nodeZ); + Edge edgeBetweenFandH = new Edge(nodeF, nodeH); - List edgesForUndirectedUnweightedGraph7 = new LinkedList(); + List edgesForUndirectedUnweightedGraph7 = new LinkedList(); edgesForUndirectedUnweightedGraph7.add(edgeBetweenAandB); edgesForUndirectedUnweightedGraph7.add(edgeBetweenAandE); edgesForUndirectedUnweightedGraph7.add(edgeBetweenAandZ); @@ -324,7 +324,7 @@ public void setUp() throws Exception { // // Graph #7: graph7.png // - UndirectedUnweightedgraph7 = new GraphClass(nodesForUndirectedUnweightedGraph7, edgesForUndirectedUnweightedGraph7); + UndirectedUnweightedgraph7 = new Graph(nodesForUndirectedUnweightedGraph7, edgesForUndirectedUnweightedGraph7); @@ -346,14 +346,14 @@ public void setUp() throws Exception { */ - GraphEdge edgeBetweenGandD = new GraphEdge(nodeG,nodeD); - GraphEdge edgeBetweenZandG = new GraphEdge(nodeZ,nodeG); - GraphEdge edgeBetweenZandD = new GraphEdge(nodeZ,nodeD); - GraphEdge edgeBetweenFandB = new GraphEdge(nodeF,nodeB); - GraphEdge edgeBetweenDandC = new GraphEdge(nodeD,nodeC); - GraphEdge edgeBetweenEandD = new GraphEdge(nodeE,nodeD); + Edge edgeBetweenGandD = new Edge(nodeG,nodeD); + Edge edgeBetweenZandG = new Edge(nodeZ,nodeG); + Edge edgeBetweenZandD = new Edge(nodeZ,nodeD); + Edge edgeBetweenFandB = new Edge(nodeF,nodeB); + Edge edgeBetweenDandC = new Edge(nodeD,nodeC); + Edge edgeBetweenEandD = new Edge(nodeE,nodeD); - List edgesForGraph8 = new LinkedList(); + List edgesForGraph8 = new LinkedList(); edgesForGraph8.add(edgeBetweenAandD); edgesForGraph8.add(edgeBetweenBandD); edgesForGraph8.add(edgeBetweenHandZ); @@ -369,7 +369,7 @@ public void setUp() throws Exception { // use nodes from graph 2 - DirectedUnweightedGraph8 = new GraphClass(nodesForUndirectedUnweightedGraph2, edgesForGraph8, true); + DirectedUnweightedGraph8 = new Graph(nodesForUndirectedUnweightedGraph2, edgesForGraph8, true); // // Graph #8: directed and unweighted // @@ -393,10 +393,10 @@ public void setUp() throws Exception { * */ - GraphEdge edgeBetweenGandA = new GraphEdge(nodeG, nodeA); - GraphEdge edgeBetweenFandA = new GraphEdge(nodeF, nodeA); + Edge edgeBetweenGandA = new Edge(nodeG, nodeA); + Edge edgeBetweenFandA = new Edge(nodeF, nodeA); - List edgesForGraph9 = new LinkedList(); + List edgesForGraph9 = new LinkedList(); edgesForGraph9.add(edgeBetweenAandB); edgesForGraph9.add(edgeBetweenBandC); edgesForGraph9.add(edgeBetweenCandE); @@ -411,7 +411,7 @@ public void setUp() throws Exception { edgesForGraph9.add(edgeBetweenFandA); - DirectedUnweightedGraph9 = new GraphClass(nodesForUndirectedUnweightedGraph2, edgesForGraph9, true); + DirectedUnweightedGraph9 = new Graph(nodesForUndirectedUnweightedGraph2, edgesForGraph9, true); // // Graph #9: directed and unweighted // @@ -432,11 +432,11 @@ public void setUp() throws Exception { * g-a */ - GraphEdge edgeBetweenZandC = new GraphEdge(nodeZ, nodeC); - GraphEdge edgeBetweenGandE = new GraphEdge(nodeG, nodeE); - GraphEdge edgeBetweenEandB = new GraphEdge(nodeE, nodeB); - GraphEdge edgeBetweenDandZ = new GraphEdge(nodeD, nodeZ); - List edgesForGraph10 = new LinkedList(); + Edge edgeBetweenZandC = new Edge(nodeZ, nodeC); + Edge edgeBetweenGandE = new Edge(nodeG, nodeE); + Edge edgeBetweenEandB = new Edge(nodeE, nodeB); + Edge edgeBetweenDandZ = new Edge(nodeD, nodeZ); + List edgesForGraph10 = new LinkedList(); edgesForGraph10.add(edgeBetweenAandD); edgesForGraph10.add(edgeBetweenAandC); edgesForGraph10.add(edgeBetweenDandC); @@ -448,7 +448,7 @@ public void setUp() throws Exception { edgesForGraph10.add(edgeBetweenDandZ); edgesForGraph10.add(edgeBetweenGandA); - DirectedUnweightedGraph10 = new GraphClass(nodesForUndirectedUnweightedGraph2, edgesForGraph10, true); + DirectedUnweightedGraph10 = new Graph(nodesForUndirectedUnweightedGraph2, edgesForGraph10, true); // // Graph #10: directed and unweighted // @@ -472,7 +472,7 @@ public void setUp() throws Exception { * * */ - List edgesForGraph11 = new LinkedList(); + List edgesForGraph11 = new LinkedList(); edgesForGraph11.add(edgeBetweenAandD.setWeight(1)); edgesForGraph11.add(edgeBetweenZandD.setWeight(2)); edgesForGraph11.add(edgeBetweenBandD.setWeight(1)); @@ -485,7 +485,7 @@ public void setUp() throws Exception { edgesForGraph11.add(edgeBetweenDandC.setWeight(1)); edgesForGraph11.add(edgeBetweenEandD.setWeight(1)); edgesForGraph11.add(edgeBetweenDandF.setWeight(1)); - DirectedWeightedGraph11 = new GraphClass(nodesForUndirectedUnweightedGraph2, edgesForGraph11, true); + DirectedWeightedGraph11 = new Graph(nodesForUndirectedUnweightedGraph2, edgesForGraph11, true); DirectedWeightedGraph11.setWeighted(true); // @@ -509,7 +509,7 @@ public void setUp() throws Exception { * f-a * */ - List edgesForGraph12 = new LinkedList(); + List edgesForGraph12 = new LinkedList(); edgesForGraph12.add(edgeBetweenAandB.setWeight(1)); edgesForGraph12.add(edgeBetweenBandC.setWeight(1)); edgesForGraph12.add(edgeBetweenCandE.setWeight(1)); @@ -522,7 +522,7 @@ public void setUp() throws Exception { edgesForGraph12.add(edgeBetweenDandF.setWeight(1)); edgesForGraph12.add(edgeBetweenGandA.setWeight(1)); edgesForGraph12.add(edgeBetweenFandA.setWeight(1)); - DirectedWeightedGraph12 = new GraphClass(nodesForUndirectedUnweightedGraph2, edgesForGraph12, true); + DirectedWeightedGraph12 = new Graph(nodesForUndirectedUnweightedGraph2, edgesForGraph12, true); DirectedWeightedGraph12.setWeighted(true); // @@ -546,7 +546,7 @@ public void setUp() throws Exception { * */ - List edgesForGraph13 = new LinkedList(); + List edgesForGraph13 = new LinkedList(); edgesForGraph13.add(edgeBetweenAandD.setWeight(1)); edgesForGraph13.add(edgeBetweenAandC.setWeight(1)); edgesForGraph13.add(edgeBetweenDandC.setWeight(1)); @@ -559,7 +559,7 @@ public void setUp() throws Exception { edgesForGraph13.add(edgeBetweenGandA.setWeight(1)); - DirectedWeightedGraph13 = new GraphClass(nodesForUndirectedUnweightedGraph2, edgesForGraph13, true); + DirectedWeightedGraph13 = new Graph(nodesForUndirectedUnweightedGraph2, edgesForGraph13, true); DirectedWeightedGraph13.setWeighted(true); // @@ -571,7 +571,7 @@ public void setUp() throws Exception { @Test public void depthFirstSearchUndirectedUnweightedGraph01() throws Exception { - List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph1, nodeA, nodeF); + List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph1, nodeA, nodeF); Assert.assertEquals(path.size(), 6); Assert.assertTrue(path.get(0).getValue().equals("A")); Assert.assertTrue(path.get(1).getValue().equals("B")); @@ -583,7 +583,7 @@ public void depthFirstSearchUndirectedUnweightedGraph01() throws Exception { @Test public void depthFirstSearchRecursiveUndirectedUnweightedGraph01() throws Exception { - List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph1, nodeA, nodeF); + List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph1, nodeA, nodeF); Assert.assertEquals(path.size(), 6); Assert.assertTrue(path.get(0).getValue().equals("A")); Assert.assertTrue(path.get(1).getValue().equals("B")); @@ -595,7 +595,7 @@ public void depthFirstSearchRecursiveUndirectedUnweightedGraph01() throws Except @Test public void breadthFirstSearchUndirectedUnweightedGraph01() throws Exception { - List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph1, nodeA, nodeF); + List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph1, nodeA, nodeF); Assert.assertEquals(path.size(), 6); Assert.assertTrue(path.get(0).getValue().equals("A")); Assert.assertTrue(path.get(1).getValue().equals("B")); @@ -607,7 +607,7 @@ public void breadthFirstSearchUndirectedUnweightedGraph01() throws Exception { @Test public void depthFirstSearchUndirectedUnweightedGraph02() throws Exception { - List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph2, nodeA, nodeH); + List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph2, nodeA, nodeH); Assert.assertEquals(path.size(), 8); Assert.assertTrue(path.get(0).getValue().equals("A")); Assert.assertTrue(path.get(1).getValue().equals("B")); @@ -621,7 +621,7 @@ public void depthFirstSearchUndirectedUnweightedGraph02() throws Exception { @Test public void depthFirstSearchRecursiveUndirectedUnweightedGraph02() throws Exception { - List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph2, nodeA, nodeH); + List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph2, nodeA, nodeH); Assert.assertEquals(path.size(), 8); Assert.assertTrue(path.get(0).getValue().equals("A")); Assert.assertTrue(path.get(1).getValue().equals("B")); @@ -635,7 +635,7 @@ public void depthFirstSearchRecursiveUndirectedUnweightedGraph02() throws Except @Test public void breadthFirstSearchUndirectedUnweightedGraph02() throws Exception { - List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph2, nodeA, nodeH); + List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph2, nodeA, nodeH); Assert.assertEquals(path.size(), 3); Assert.assertTrue(path.get(0).getValue().equals("A")); Assert.assertTrue(path.get(1).getValue().equals("Z")); @@ -644,7 +644,7 @@ public void breadthFirstSearchUndirectedUnweightedGraph02() throws Exception { @Test public void depthFirstSearchUndirectedUnweightedGraph03() throws Exception { - List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph3, nodeB, nodeE); + List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph3, nodeB, nodeE); Assert.assertEquals(path.size(), 6); Assert.assertTrue(path.get(0).getValue().equals("B")); Assert.assertTrue(path.get(1).getValue().equals("C")); @@ -656,7 +656,7 @@ public void depthFirstSearchUndirectedUnweightedGraph03() throws Exception { @Test public void depthFirstSearchRecursiveUndirectedUnweightedGraph03() throws Exception { - List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph3, nodeB, nodeE); + List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph3, nodeB, nodeE); Assert.assertEquals(path.size(), 6); Assert.assertTrue(path.get(0).getValue().equals("B")); Assert.assertTrue(path.get(1).getValue().equals("C")); @@ -668,7 +668,7 @@ public void depthFirstSearchRecursiveUndirectedUnweightedGraph03() throws Except @Test public void breadthFirstSearchUndirectedUnweightedGraph03() throws Exception { - List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph3, nodeB, nodeE); + List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph3, nodeB, nodeE); Assert.assertEquals(path.size(), 5); Assert.assertTrue(path.get(0).getValue().equals("B")); Assert.assertTrue(path.get(1).getValue().equals("D")); @@ -679,7 +679,7 @@ public void breadthFirstSearchUndirectedUnweightedGraph03() throws Exception { @Test public void depthFirstSearchUndirectedUnweightedGraph04() throws Exception { - List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph4, nodeB, nodeF); + List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph4, nodeB, nodeF); Assert.assertEquals(path.size(), 7); Assert.assertTrue(path.get(0).getValue().equals("B")); Assert.assertTrue(path.get(1).getValue().equals("E")); @@ -692,7 +692,7 @@ public void depthFirstSearchUndirectedUnweightedGraph04() throws Exception { @Test public void depthFirstSearchRecursiveUndirectedUnweightedGraph04() throws Exception { - List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph4, nodeB, nodeF); + List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph4, nodeB, nodeF); Assert.assertEquals(path.size(), 7); Assert.assertTrue(path.get(0).getValue().equals("B")); Assert.assertTrue(path.get(1).getValue().equals("E")); @@ -705,7 +705,7 @@ public void depthFirstSearchRecursiveUndirectedUnweightedGraph04() throws Except @Test public void breadthFirstSearchUndirectedUnweightedGraph04() throws Exception { - List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph4, nodeB, nodeF); + List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph4, nodeB, nodeF); Assert.assertEquals(path.size(), 4); Assert.assertTrue(path.get(0).getValue().equals("B")); Assert.assertTrue(path.get(1).getValue().equals("H")); @@ -715,37 +715,37 @@ public void breadthFirstSearchUndirectedUnweightedGraph04() throws Exception { @Test public void depthFirstSearchUndirectedUnweightedGraph05() throws Exception { - List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph5, nodeA, nodeZ); + List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph5, nodeA, nodeZ); Assert.assertEquals(path.size(), 0); } @Test public void depthFirstSearchRecursiveUndirectedUnweightedGraph05() throws Exception { - List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph5, nodeA, nodeZ); + List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph5, nodeA, nodeZ); Assert.assertEquals(path.size(), 0); } @Test public void breadthFirstSearchUndirectedUnweightedGraph05() throws Exception { - List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph5, nodeA, nodeZ); + List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph5, nodeA, nodeZ); Assert.assertEquals(path.size(), 0); } @Test public void depthFirstSearchUndirectedUnweightedGraph06() throws Exception { - List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph6, nodeA, nodeF); + List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph6, nodeA, nodeF); Assert.assertEquals(path.size(), 6); } @Test public void depthFirstSearchRecursiveUndirectedUnweightedGraph06() throws Exception { - List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph6, nodeA, nodeF); + List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph6, nodeA, nodeF); Assert.assertEquals(path.size(), 6); } @Test public void breadthFirstSearchUndirectedUnweightedGraph06() throws Exception { - List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph6, nodeA, nodeF); + List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph6, nodeA, nodeF); Assert.assertEquals(path.size(), 2); Assert.assertTrue(path.get(0).getValue().equals("A")); Assert.assertTrue(path.get(1).getValue().equals("F")); @@ -753,19 +753,19 @@ public void breadthFirstSearchUndirectedUnweightedGraph06() throws Exception { @Test public void depthFirstSearchUndirectedUnweightedGraph07() throws Exception { - List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph7, nodeA, nodeF); + List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph7, nodeA, nodeF); Assert.assertEquals(path.size(), 6); } @Test public void depthFirstSearchRecursiveUndirectedUnweightedGraph07() throws Exception { - List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph7, nodeA, nodeF); + List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph7, nodeA, nodeF); Assert.assertEquals(path.size(), 6); } @Test public void breadthFirstSearchUndirectedUnweightedGraph07() throws Exception { - List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph7, nodeA, nodeF); + List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph7, nodeA, nodeF); Assert.assertEquals(path.size(), 4); Assert.assertTrue(path.get(0).getValue().equals("A")); Assert.assertTrue(path.get(1).getValue().equals("E")); @@ -776,7 +776,7 @@ public void breadthFirstSearchUndirectedUnweightedGraph07() throws Exception { @Test public void depthFirstSearchNullStartNode() throws Exception { thrown.expect(IllegalArgumentException.class); - List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph5, null, nodeZ); + List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph5, null, nodeZ); // the expect message is thrown if the thrown var doesnt catch it's appropriate exception? // ie this message doesn't need to match the message of the thrown exception in GraphSearch.java, correct? thrown.expectMessage("expect message"); @@ -785,21 +785,21 @@ public void depthFirstSearchNullStartNode() throws Exception { @Test public void depthFirstSearchRecursiveNullStartNode() throws Exception { thrown.expect(IllegalArgumentException.class); - List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph5, null, nodeZ); + List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph5, null, nodeZ); thrown.expectMessage("expect message"); } @Test public void breadthFirstSearchNullStartNode() throws Exception { thrown.expect(IllegalArgumentException.class); - List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph5, null, nodeZ); + List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph5, null, nodeZ); thrown.expectMessage("expect message"); } @Test public void depthFirstSearchNullFinishNode() throws Exception { thrown.expect(IllegalArgumentException.class); - List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph5, nodeA, null); + List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph5, nodeA, null); // the expect message is thrown if the thrown var doesnt catch it's appropriate exception? // ie this message doesn't need to match the message of the thrown exception in GraphSearch.java, correct? thrown.expectMessage("expect message"); @@ -808,98 +808,98 @@ public void depthFirstSearchNullFinishNode() throws Exception { @Test public void depthFirstSearchRecursiveNullFinishNode() throws Exception { thrown.expect(IllegalArgumentException.class); - List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph5, nodeA, null); + List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph5, nodeA, null); thrown.expectMessage("expect message"); } @Test public void breadthFirstSearchNullFinishNode() throws Exception { thrown.expect(IllegalArgumentException.class); - List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph5, nodeA, null); + List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph5, nodeA, null); thrown.expectMessage("expect message"); } @Test public void depthFirstSearchOutFinishNode() throws Exception { - List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph1, nodeA, nodeZ); + List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph1, nodeA, nodeZ); Assert.assertEquals(path.size(), 0); } @Test public void depthFirstSearchRecursiveOutFinishNode() throws Exception { - List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph1, nodeA, nodeZ); + List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph1, nodeA, nodeZ); Assert.assertEquals(path.size(), 0); } @Test public void breadthFirstSearchOutFinishNode() throws Exception { - List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph1, nodeA, nodeZ); + List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph1, nodeA, nodeZ); Assert.assertEquals(path.size(), 0); } @Test public void depthFirstSearchOutStartNode() throws Exception { - List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph1, nodeZ, nodeA); + List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph1, nodeZ, nodeA); Assert.assertEquals(path.size(), 0); } @Test public void depthFirstSearchRecursiveOutStartNode() throws Exception { - List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph1, nodeZ, nodeA); + List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph1, nodeZ, nodeA); Assert.assertEquals(path.size(), 0); } @Test public void breadthFirstSearchOutStartNode() throws Exception { - List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph1, nodeZ, nodeA); + List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph1, nodeZ, nodeA); Assert.assertEquals(path.size(), 0); } @Test public void depthFirstSearchNullGraph() throws Exception { thrown.expect(IllegalArgumentException.class); - List path = GraphSearch.depthFirstSearch(null, nodeA, nodeZ); + List path = GraphSearch.depthFirstSearch(null, nodeA, nodeZ); thrown.expectMessage("expect message"); } @Test public void depthFirstSearchRecursiveNullGraph() throws Exception { thrown.expect(IllegalArgumentException.class); - List path = GraphSearch.depthFirstSearchRecursive(null, nodeA, nodeZ); + List path = GraphSearch.depthFirstSearchRecursive(null, nodeA, nodeZ); thrown.expectMessage("expect message"); } @Test public void breadthFirstSearchNullGraph() throws Exception { thrown.expect(IllegalArgumentException.class); - List path = GraphSearch.breadthFirstSearch(null, nodeA, nodeZ); + List path = GraphSearch.breadthFirstSearch(null, nodeA, nodeZ); thrown.expectMessage("expect message"); } @Test public void depthFirstSearchEmptyGraph() throws Exception { thrown.expect(IllegalArgumentException.class); - List path = GraphSearch.depthFirstSearch(new GraphClass(), nodeA, nodeZ); + List path = GraphSearch.depthFirstSearch(new Graph(), nodeA, nodeZ); thrown.expectMessage("expect message"); } @Test public void depthFirstSearchRecursiveEmptyGraph() throws Exception { thrown.expect(IllegalArgumentException.class); - List path = GraphSearch.depthFirstSearchRecursive(new GraphClass(), nodeA, nodeZ); + List path = GraphSearch.depthFirstSearchRecursive(new Graph(), nodeA, nodeZ); thrown.expectMessage("expect message"); } @Test public void breadthFirstSearchEmptyGraph() throws Exception { thrown.expect(IllegalArgumentException.class); - List path = GraphSearch.breadthFirstSearch(new GraphClass(), nodeA, nodeZ); + List path = GraphSearch.breadthFirstSearch(new Graph(), nodeA, nodeZ); thrown.expectMessage("expect message"); } @Test public void depthFirstSearchDirectedUnweightedGraph08() throws Exception { - List path = GraphSearch.depthFirstSearch(DirectedUnweightedGraph8, nodeH, nodeB); + List path = GraphSearch.depthFirstSearch(DirectedUnweightedGraph8, nodeH, nodeB); Assert.assertEquals(path.size(), 6); Assert.assertTrue(path.get(0).getValue().equals("H")); Assert.assertTrue(path.get(1).getValue().equals("Z")); @@ -911,7 +911,7 @@ public void depthFirstSearchDirectedUnweightedGraph08() throws Exception { @Test public void depthFirstSearchRecursiveDirectedUnweightedGraph08() throws Exception { - List path = GraphSearch.depthFirstSearchRecursive(DirectedUnweightedGraph8, nodeH, nodeB); + List path = GraphSearch.depthFirstSearchRecursive(DirectedUnweightedGraph8, nodeH, nodeB); Assert.assertEquals(path.size(), 6); Assert.assertTrue(path.get(0).getValue().equals("H")); Assert.assertTrue(path.get(1).getValue().equals("Z")); @@ -923,7 +923,7 @@ public void depthFirstSearchRecursiveDirectedUnweightedGraph08() throws Exceptio @Test public void breadthFirstSearchDirectedUnweightedGraph08() throws Exception { - List path = GraphSearch.breadthFirstSearch(DirectedUnweightedGraph8, nodeH, nodeB); + List path = GraphSearch.breadthFirstSearch(DirectedUnweightedGraph8, nodeH, nodeB); Assert.assertEquals(path.size(), 5); Assert.assertTrue(path.get(0).getValue().equals("H")); Assert.assertTrue(path.get(1).getValue().equals("Z")); @@ -934,7 +934,7 @@ public void breadthFirstSearchDirectedUnweightedGraph08() throws Exception { @Test public void depthFirstSearchDirectedUnweightedGraph09() throws Exception { - List path = GraphSearch.depthFirstSearch(DirectedUnweightedGraph9, nodeE, nodeF); + List path = GraphSearch.depthFirstSearch(DirectedUnweightedGraph9, nodeE, nodeF); Assert.assertEquals(path.size(), 5); Assert.assertTrue(path.get(0).getValue().equals("E")); Assert.assertTrue(path.get(1).getValue().equals("Z")); @@ -945,7 +945,7 @@ public void depthFirstSearchDirectedUnweightedGraph09() throws Exception { @Test public void depthFirstSearchRecursiveDirectedUnweightedGraph09() throws Exception { - List path = GraphSearch.depthFirstSearchRecursive(DirectedUnweightedGraph9, nodeE, nodeF); + List path = GraphSearch.depthFirstSearchRecursive(DirectedUnweightedGraph9, nodeE, nodeF); Assert.assertEquals(path.size(), 5); Assert.assertTrue(path.get(0).getValue().equals("E")); Assert.assertTrue(path.get(1).getValue().equals("Z")); @@ -956,7 +956,7 @@ public void depthFirstSearchRecursiveDirectedUnweightedGraph09() throws Exceptio @Test public void breadthFirstSearchDirectedUnweightedGraph09() throws Exception { - List path = GraphSearch.breadthFirstSearch(DirectedUnweightedGraph9, nodeE, nodeF); + List path = GraphSearch.breadthFirstSearch(DirectedUnweightedGraph9, nodeE, nodeF); Assert.assertEquals(path.size(), 3); Assert.assertTrue(path.get(0).getValue().equals("E")); Assert.assertTrue(path.get(1).getValue().equals("D")); @@ -965,7 +965,7 @@ public void breadthFirstSearchDirectedUnweightedGraph09() throws Exception { @Test public void depthFirstSearchDirectedUnweightedGraph10() throws Exception { - List path = GraphSearch.depthFirstSearch(DirectedUnweightedGraph10, nodeG, nodeH); + List path = GraphSearch.depthFirstSearch(DirectedUnweightedGraph10, nodeG, nodeH); Assert.assertEquals(path.size(), 5); Assert.assertTrue(path.get(0).getValue().equals("G")); Assert.assertTrue(path.get(1).getValue().equals("E")); @@ -976,7 +976,7 @@ public void depthFirstSearchDirectedUnweightedGraph10() throws Exception { @Test public void depthFirstSearchRecursiveDirectedUnweightedGraph10() throws Exception { - List path = GraphSearch.depthFirstSearchRecursive(DirectedUnweightedGraph10, nodeG, nodeH); + List path = GraphSearch.depthFirstSearchRecursive(DirectedUnweightedGraph10, nodeG, nodeH); Assert.assertEquals(path.size(), 5); Assert.assertTrue(path.get(0).getValue().equals("G")); Assert.assertTrue(path.get(1).getValue().equals("E")); @@ -987,7 +987,7 @@ public void depthFirstSearchRecursiveDirectedUnweightedGraph10() throws Exceptio @Test public void breadthFirstSearchDirectedUnweightedGraph10() throws Exception { - List path = GraphSearch.breadthFirstSearch(DirectedUnweightedGraph10, nodeG, nodeH); + List path = GraphSearch.breadthFirstSearch(DirectedUnweightedGraph10, nodeG, nodeH); Assert.assertEquals(path.size(), 5); Assert.assertTrue(path.get(0).getValue().equals("G")); Assert.assertTrue(path.get(1).getValue().equals("E")); @@ -998,7 +998,7 @@ public void breadthFirstSearchDirectedUnweightedGraph10() throws Exception { @Test public void depthFirstSearchDirectedWeightedGraph11() throws Exception { - List path = GraphSearch.depthFirstSearch(DirectedWeightedGraph11, nodeH, nodeB); + List path = GraphSearch.depthFirstSearch(DirectedWeightedGraph11, nodeH, nodeB); Assert.assertEquals(path.size(), 6); Assert.assertTrue(path.get(0).getValue().equals("H")); Assert.assertTrue(path.get(1).getValue().equals("Z")); @@ -1010,7 +1010,7 @@ public void depthFirstSearchDirectedWeightedGraph11() throws Exception { @Test public void depthFirstSearchRecursiveDirectedWeightedGraph11() throws Exception { - List path = GraphSearch.depthFirstSearchRecursive(DirectedWeightedGraph11, nodeH, nodeB); + List path = GraphSearch.depthFirstSearchRecursive(DirectedWeightedGraph11, nodeH, nodeB); Assert.assertEquals(path.size(), 6); Assert.assertTrue(path.get(0).getValue().equals("H")); Assert.assertTrue(path.get(1).getValue().equals("Z")); @@ -1022,7 +1022,7 @@ public void depthFirstSearchRecursiveDirectedWeightedGraph11() throws Exception @Test public void breadthFirstSearchDirectedWeightedGraph11() throws Exception { - List path = GraphSearch.breadthFirstSearch(DirectedWeightedGraph11, nodeH, nodeB); + List path = GraphSearch.breadthFirstSearch(DirectedWeightedGraph11, nodeH, nodeB); Assert.assertEquals(path.size(), 5); Assert.assertTrue(path.get(0).getValue().equals("H")); Assert.assertTrue(path.get(1).getValue().equals("Z")); @@ -1033,7 +1033,7 @@ public void breadthFirstSearchDirectedWeightedGraph11() throws Exception { @Test public void depthFirstSearchDirectedWeightedGraph12() throws Exception { - List path = GraphSearch.depthFirstSearch(DirectedWeightedGraph12, nodeE, nodeF); + List path = GraphSearch.depthFirstSearch(DirectedWeightedGraph12, nodeE, nodeF); Assert.assertEquals(path.size(), 5); Assert.assertTrue(path.get(0).getValue().equals("E")); Assert.assertTrue(path.get(1).getValue().equals("Z")); @@ -1044,7 +1044,7 @@ public void depthFirstSearchDirectedWeightedGraph12() throws Exception { @Test public void depthFirstSearchRecursiveDirectedWeightedGraph12() throws Exception { - List path = GraphSearch.depthFirstSearchRecursive(DirectedWeightedGraph12, nodeE, nodeF); + List path = GraphSearch.depthFirstSearchRecursive(DirectedWeightedGraph12, nodeE, nodeF); Assert.assertEquals(path.size(), 5); Assert.assertTrue(path.get(0).getValue().equals("E")); Assert.assertTrue(path.get(1).getValue().equals("Z")); @@ -1055,7 +1055,7 @@ public void depthFirstSearchRecursiveDirectedWeightedGraph12() throws Exception @Test public void breadthFirstSearchDirectedWeightedGraph12() throws Exception { - List path = GraphSearch.breadthFirstSearch(DirectedWeightedGraph12, nodeE, nodeF); + List path = GraphSearch.breadthFirstSearch(DirectedWeightedGraph12, nodeE, nodeF); Assert.assertEquals(path.size(), 3); Assert.assertTrue(path.get(0).getValue().equals("E")); Assert.assertTrue(path.get(1).getValue().equals("D")); @@ -1064,7 +1064,7 @@ public void breadthFirstSearchDirectedWeightedGraph12() throws Exception { @Test public void depthFirstSearchDirectedWeightedGraph13() throws Exception { - List path = GraphSearch.depthFirstSearch(DirectedWeightedGraph13, nodeG, nodeH); + List path = GraphSearch.depthFirstSearch(DirectedWeightedGraph13, nodeG, nodeH); Assert.assertEquals(path.size(), 5); Assert.assertTrue(path.get(0).getValue().equals("G")); Assert.assertTrue(path.get(1).getValue().equals("E")); @@ -1075,7 +1075,7 @@ public void depthFirstSearchDirectedWeightedGraph13() throws Exception { @Test public void depthFirstSearchRecursiveDirectedWeightedGraph13() throws Exception { - List path = GraphSearch.depthFirstSearchRecursive(DirectedWeightedGraph13, nodeG, nodeH); + List path = GraphSearch.depthFirstSearchRecursive(DirectedWeightedGraph13, nodeG, nodeH); Assert.assertEquals(path.size(), 5); Assert.assertTrue(path.get(0).getValue().equals("G")); Assert.assertTrue(path.get(1).getValue().equals("E")); @@ -1086,7 +1086,7 @@ public void depthFirstSearchRecursiveDirectedWeightedGraph13() throws Exception @Test public void breadthFirstSearchDirectedWeightedGraph13() throws Exception { - List path = GraphSearch.breadthFirstSearch(DirectedWeightedGraph13, nodeG, nodeH); + List path = GraphSearch.breadthFirstSearch(DirectedWeightedGraph13, nodeG, nodeH); Assert.assertEquals(path.size(), 5); Assert.assertTrue(path.get(0).getValue().equals("G")); Assert.assertTrue(path.get(1).getValue().equals("E")); @@ -1098,19 +1098,19 @@ public void breadthFirstSearchDirectedWeightedGraph13() throws Exception { // same as graph 13, except start at e and look for c, un connected, will need to restart @Test public void depthFirstSearchDirectedWeightedGraph14() throws Exception { - List path = GraphSearch.depthFirstSearch(DirectedWeightedGraph13, nodeE, nodeC); + List path = GraphSearch.depthFirstSearch(DirectedWeightedGraph13, nodeE, nodeC); Assert.assertEquals(path.size(), 0); } @Test public void depthFirstSearchRecursiveDirectedWeightedGraph14() throws Exception { - List path = GraphSearch.depthFirstSearchRecursive(DirectedWeightedGraph13, nodeE, nodeC); + List path = GraphSearch.depthFirstSearchRecursive(DirectedWeightedGraph13, nodeE, nodeC); Assert.assertEquals(path.size(), 0); } @Test public void breadthFirstSearchDirectedWeightedGraph14() throws Exception { - List path = GraphSearch.breadthFirstSearch(DirectedWeightedGraph13, nodeE, nodeC); + List path = GraphSearch.breadthFirstSearch(DirectedWeightedGraph13, nodeE, nodeC); Assert.assertEquals(path.size(), 0); } From 1be5c14e37bd345f129a77ddc8a7e444b5e0966b Mon Sep 17 00:00:00 2001 From: sam Date: Wed, 19 Oct 2016 22:31:35 -0500 Subject: [PATCH 06/10] renames classes and improves compareTo --- .idea/misc.xml | 73 ++++++++++--------- .../1748581304/coding-exercises_main.iml | 3 +- .../1748581304/coding-exercises_test.iml | 3 +- src/main/java/graphs/Edge.java | 8 +- src/main/java/graphs/Graph.java | 9 ++- 5 files changed, 53 insertions(+), 43 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 9271fca..9468b8a 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,24 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - Android - - - - - @@ -30,21 +52,6 @@ - - - - - - - - - - - - + - + \ No newline at end of file diff --git a/.idea/modules/1748581304/coding-exercises_main.iml b/.idea/modules/1748581304/coding-exercises_main.iml index cf38f7a..149c103 100644 --- a/.idea/modules/1748581304/coding-exercises_main.iml +++ b/.idea/modules/1748581304/coding-exercises_main.iml @@ -5,8 +5,9 @@ + - + \ No newline at end of file diff --git a/.idea/modules/1748581304/coding-exercises_test.iml b/.idea/modules/1748581304/coding-exercises_test.iml index 31fda24..bb499ef 100644 --- a/.idea/modules/1748581304/coding-exercises_test.iml +++ b/.idea/modules/1748581304/coding-exercises_test.iml @@ -5,6 +5,7 @@ + @@ -13,4 +14,4 @@ - + \ No newline at end of file diff --git a/src/main/java/graphs/Edge.java b/src/main/java/graphs/Edge.java index af54f03..69a174b 100644 --- a/src/main/java/graphs/Edge.java +++ b/src/main/java/graphs/Edge.java @@ -67,13 +67,7 @@ public Node getOtherNode(Node node) { // "Note: this class has a natural ordering that is inconsistent with equals." public int compareTo(Edge edge) { - // is it necessary to specify "this." ? - if(edge.getWeight() > this.getWeight()) { - return -1; - } else if (this.getWeight() > edge.getWeight()){ - return 1; - } - return 0; + return Double.compare(this.getWeight(), edge.getWeight()); } } diff --git a/src/main/java/graphs/Graph.java b/src/main/java/graphs/Graph.java index 2e41ed5..279f0ad 100644 --- a/src/main/java/graphs/Graph.java +++ b/src/main/java/graphs/Graph.java @@ -1,6 +1,13 @@ package graphs; -import java.util.*; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.LinkedList; +import java.util.Collections; + public class Graph { private List edges; From e8dee03d817672918ac576f1e47c1c33130b28d6 Mon Sep 17 00:00:00 2001 From: sam Date: Sun, 30 Oct 2016 19:42:32 -0500 Subject: [PATCH 07/10] adds djikstras algo and refactors test suite --- .gitignore | 1 + .idea/compiler.xml | 4 - .idea/misc.xml | 42 +- .idea/modules.xml | 2 - .idea/modules/1748581304/coding-exercises.iml | 10 +- .../1748581304/coding-exercises_main.iml | 13 - .../1748581304/coding-exercises_test.iml | 17 - src/main/java/graphs/GraphSearch.java | 100 +++ .../graphs/DirectedUnweightedGraphTest.java | 340 +++++++++++ .../graphs/DirectedWeightedGraphTest.java | 317 ++++++++++ src/test/java/graphs/GraphSearchTest.java | 8 +- src/test/java/graphs/GraphTestSuite.java | 18 + src/test/java/graphs/SpecialGraphTest.java | 219 +++++++ .../graphs/UndirectedUnweightedGraphTest.java | 574 ++++++++++++++++++ .../graphs/UndirectedWeightedGraphTest.java | 354 +++++++++++ src/test/java/graphs/graph5.png | Bin 0 -> 11687 bytes src/test/java/graphs/graph6.png | Bin 0 -> 24255 bytes src/test/java/graphs/graph7.png | Bin 0 -> 14623 bytes 18 files changed, 1938 insertions(+), 81 deletions(-) delete mode 100644 .idea/modules/1748581304/coding-exercises_main.iml delete mode 100644 .idea/modules/1748581304/coding-exercises_test.iml create mode 100644 src/test/java/graphs/DirectedUnweightedGraphTest.java create mode 100644 src/test/java/graphs/DirectedWeightedGraphTest.java create mode 100644 src/test/java/graphs/GraphTestSuite.java create mode 100644 src/test/java/graphs/SpecialGraphTest.java create mode 100644 src/test/java/graphs/UndirectedUnweightedGraphTest.java create mode 100644 src/test/java/graphs/UndirectedWeightedGraphTest.java create mode 100644 src/test/java/graphs/graph5.png create mode 100644 src/test/java/graphs/graph6.png create mode 100644 src/test/java/graphs/graph7.png diff --git a/.gitignore b/.gitignore index 2434886..9de69da 100644 --- a/.gitignore +++ b/.gitignore @@ -53,3 +53,4 @@ gradle-app.setting # gimp image file to make pngs of graphs for tests *.xcf +.idea/ diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 52adc4f..96cc43e 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -18,9 +18,5 @@ - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 9468b8a..10be079 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,43 +1,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -51,7 +13,7 @@ - - + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml index fd3e04d..1fc19bc 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -3,8 +3,6 @@ - - \ No newline at end of file diff --git a/.idea/modules/1748581304/coding-exercises.iml b/.idea/modules/1748581304/coding-exercises.iml index 100c00b..e63c3ee 100644 --- a/.idea/modules/1748581304/coding-exercises.iml +++ b/.idea/modules/1748581304/coding-exercises.iml @@ -1,12 +1,20 @@ - + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules/1748581304/coding-exercises_main.iml b/.idea/modules/1748581304/coding-exercises_main.iml deleted file mode 100644 index 149c103..0000000 --- a/.idea/modules/1748581304/coding-exercises_main.iml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules/1748581304/coding-exercises_test.iml b/.idea/modules/1748581304/coding-exercises_test.iml deleted file mode 100644 index bb499ef..0000000 --- a/.idea/modules/1748581304/coding-exercises_test.iml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/java/graphs/GraphSearch.java b/src/main/java/graphs/GraphSearch.java index 246d2b5..f9f597a 100644 --- a/src/main/java/graphs/GraphSearch.java +++ b/src/main/java/graphs/GraphSearch.java @@ -1,6 +1,7 @@ package graphs; import java.util.*; +import java.util.stream.Collectors; public class GraphSearch { @@ -158,4 +159,103 @@ private static List getPathHome(List transitions, Node start, Node f } return nodeList; } + + + /* + djikstras algo: + takes: graph, source, target + + map of V to distance from source + - instantiate at MAX_INT + map of V's previous node + + set of V + + // set source distance to zero + distanceMap.put(source, 0) + while(! setOfV.isEmpty()) + + Node currentNode = setOfV.pop() + update distance values for all nodes from nextNode + ie get incident edges and + update distance for each node = min(distance(node), distance(currentNode) + edge(currentNode, nextNode).getWeight()) + if distance < current distance + edge weight + update distance + update previous node + + // sort algo that takes list of nodes and map to their current distances and sorts nodes + find next node that is ! in settled and shortest distance (ie distance(currentNode) + edge(currentNode, nextNode).getWeight()) + shortest distance nextNode gets added to settled + + eventually every node will have a non infinite distance from source + + + */ + + public static List djikstraShortestPath(Graph graph, Node start, Node finish) { + if (graph == null || graph.isEmpty()) { + throw new IllegalArgumentException("empty or null graph"); + } + if(start == null || finish == null) { + throw new IllegalArgumentException("null start node or target node"); + } + if(! (graph.getNodes().contains(start) && graph.getNodes().contains(finish))) { + return new LinkedList(); + } + + LinkedList nodes = new LinkedList<>(graph.getNodes()); + + HashMap distanceMap = new HashMap<>(); + for(Node node : nodes) { + distanceMap.put(node, Double.valueOf(Double.MAX_VALUE)); + } + HashMap previousNodeMap = new HashMap<>(); + + distanceMap.put(start, Double.valueOf(0)); + while(! distanceMap.isEmpty()) { + Node currentNode = getShortestDistanceNode(distanceMap); + if(currentNode.equals(finish)) { + break; + } + double currentDistance = distanceMap.get(currentNode); + distanceMap.remove(currentNode); + List incidentEdges = graph.getIncidentEdges(currentNode); + for(Edge edge : incidentEdges) { + Node nextNode = edge.getRightNode(); + if(distanceMap.containsKey(nextNode)){ + double newDistance = currentDistance + edge.getWeight(); + if(newDistance < distanceMap.get(nextNode)) { + distanceMap.put(nextNode, newDistance); + // previousNodeMap will be a map of all nodes to their previous node + previousNodeMap.put(nextNode, currentNode); + } + } + } + } + if(! previousNodeMap.containsKey(finish)) { + return new LinkedList(); + } + LinkedList transitions = new LinkedList(); + HashSet keys = new HashSet(previousNodeMap.keySet()); + Node nextNode = finish; + keys.remove(nextNode); + while(! keys.isEmpty()) { + Node currentNode = previousNodeMap.get(nextNode); + transitions.addFirst(new Edge(currentNode, nextNode)); + if(currentNode.equals(start)) { + break; + } + nextNode = currentNode; + keys.remove(nextNode); + } + return getPathHome(transitions, start, finish); + } + + private static Node getShortestDistanceNode(HashMap nodeMap) { + return nodeMap.entrySet() + .stream() + .sorted(Map.Entry.comparingByValue()) + .findFirst().get().getKey(); + + } } diff --git a/src/test/java/graphs/DirectedUnweightedGraphTest.java b/src/test/java/graphs/DirectedUnweightedGraphTest.java new file mode 100644 index 0000000..9ed7f52 --- /dev/null +++ b/src/test/java/graphs/DirectedUnweightedGraphTest.java @@ -0,0 +1,340 @@ +package graphs; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; + +public class DirectedUnweightedGraphTest { + + private Node nodeA; + private Node nodeB; + private Node nodeC; + private Node nodeD; + private Node nodeE; + private Node nodeF; + private Node nodeG; + private Node nodeH; + private Node nodeZ; + + private Graph DirectedUnweightedGraph8, + DirectedUnweightedGraph9, + DirectedUnweightedGraph10; + + + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Before + public void setUp() throws Exception { + nodeA = new Node("A"); + nodeB = new Node("B"); + nodeC = new Node("C"); + nodeD = new Node("D"); + nodeE = new Node("E"); + nodeF = new Node("F"); + nodeG = new Node("G"); + nodeH = new Node("H"); + nodeZ = new Node("Z"); + + List nodesForUndirectedUnweightedGraph1 = new LinkedList(Arrays.asList( + nodeA, + nodeB, + nodeC, + nodeD, + nodeE, + nodeF + )); + + + List nodesForUndirectedUnweightedGraph2 = new LinkedList(Arrays.asList( + nodeA, + nodeB, + nodeC, + nodeD, + nodeE, + nodeF, + nodeG, + nodeH, + nodeZ + )); + + Edge edgeBetweenAandB = new Edge(nodeA, nodeB); + Edge edgeBetweenBandC = new Edge(nodeB, nodeC); + Edge edgeBetweenHandZ = new Edge(nodeH, nodeZ); + Edge edgeBetweenEandZ = new Edge(nodeE, nodeZ); + Edge edgeBetweenDandF = new Edge(nodeD, nodeF); + Edge edgeBetweenBandD = new Edge(nodeB, nodeD); + Edge edgeBetweenAandD = new Edge(nodeA, nodeD); + Edge edgeBetweenBandH = new Edge(nodeB, nodeH); + Edge edgeBetweenCandE = new Edge(nodeC, nodeE); + Edge edgeBetweenBandF = new Edge(nodeB, nodeF); + Edge edgeBetweenAandC = new Edge(nodeA, nodeC); + Edge edgeBetweenFandH = new Edge(nodeF, nodeH); + + /* + * graph 8 + * 12 edges + * a-d ~ + * b-d ~ + * g-d + * z-g + * z-d + * h-z ~ + * b-h ~ + * f-b + * c-e ~ + * d-c + * e-d + * d-f + */ + + + Edge edgeBetweenGandD = new Edge(nodeG,nodeD); + Edge edgeBetweenZandG = new Edge(nodeZ,nodeG); + Edge edgeBetweenZandD = new Edge(nodeZ,nodeD); + Edge edgeBetweenFandB = new Edge(nodeF,nodeB); + Edge edgeBetweenDandC = new Edge(nodeD,nodeC); + Edge edgeBetweenEandD = new Edge(nodeE,nodeD); + + List edgesForGraph8 = new LinkedList(); + edgesForGraph8.add(edgeBetweenAandD); + edgesForGraph8.add(edgeBetweenBandD); + edgesForGraph8.add(edgeBetweenHandZ); + edgesForGraph8.add(edgeBetweenBandH); + edgesForGraph8.add(edgeBetweenCandE); + edgesForGraph8.add(edgeBetweenGandD); + edgesForGraph8.add(edgeBetweenZandG); + edgesForGraph8.add(edgeBetweenZandD); + edgesForGraph8.add(edgeBetweenFandB); + edgesForGraph8.add(edgeBetweenDandC); + edgesForGraph8.add(edgeBetweenEandD); + edgesForGraph8.add(edgeBetweenDandF); + + + // use nodes from graph 2 + DirectedUnweightedGraph8 = new Graph(nodesForUndirectedUnweightedGraph2, edgesForGraph8, true); + // + // Graph #8: directed and unweighted + // + + + /* + * graph 9 + * 12 edges + * a-b + * b-c + * c-e + * e-d + * g-d + * g-a + * z-g + * h-z + * f-h + * d-f + * e-z + * f-a + * + */ + + Edge edgeBetweenGandA = new Edge(nodeG, nodeA); + Edge edgeBetweenFandA = new Edge(nodeF, nodeA); + + List edgesForGraph9 = new LinkedList(); + edgesForGraph9.add(edgeBetweenAandB); + edgesForGraph9.add(edgeBetweenBandC); + edgesForGraph9.add(edgeBetweenCandE); + edgesForGraph9.add(edgeBetweenEandZ); + edgesForGraph9.add(edgeBetweenEandD); + edgesForGraph9.add(edgeBetweenGandD); + edgesForGraph9.add(edgeBetweenZandG); + edgesForGraph9.add(edgeBetweenHandZ); + edgesForGraph9.add(edgeBetweenFandH); + edgesForGraph9.add(edgeBetweenDandF); + edgesForGraph9.add(edgeBetweenGandA); + edgesForGraph9.add(edgeBetweenFandA); + + + DirectedUnweightedGraph9 = new Graph(nodesForUndirectedUnweightedGraph2, edgesForGraph9, true); + // + // Graph #9: directed and unweighted + // + + + /* + * graph 10 + * 10 edges + * a-d + * a-c + * d-c + * z-c + * g-e + * e-b + * b-f + * f-h + * d-z + * g-a + */ + + Edge edgeBetweenZandC = new Edge(nodeZ, nodeC); + Edge edgeBetweenGandE = new Edge(nodeG, nodeE); + Edge edgeBetweenEandB = new Edge(nodeE, nodeB); + Edge edgeBetweenDandZ = new Edge(nodeD, nodeZ); + List edgesForGraph10 = new LinkedList(); + edgesForGraph10.add(edgeBetweenAandD); + edgesForGraph10.add(edgeBetweenAandC); + edgesForGraph10.add(edgeBetweenDandC); + edgesForGraph10.add(edgeBetweenBandF); + edgesForGraph10.add(edgeBetweenFandH); + edgesForGraph10.add(edgeBetweenZandC); + edgesForGraph10.add(edgeBetweenGandE); + edgesForGraph10.add(edgeBetweenEandB); + edgesForGraph10.add(edgeBetweenDandZ); + edgesForGraph10.add(edgeBetweenGandA); + + DirectedUnweightedGraph10 = new Graph(nodesForUndirectedUnweightedGraph2, edgesForGraph10, true); + // + // Graph #10: directed and unweighted + // + + + + } + + @Test + public void depthFirstSearchDirectedUnweightedGraph08() throws Exception { + List path = GraphSearch.depthFirstSearch(DirectedUnweightedGraph8, nodeH, nodeB); + Assert.assertEquals(path.size(), 6); + Assert.assertTrue(path.get(0).getValue().equals("H")); + Assert.assertTrue(path.get(1).getValue().equals("Z")); + Assert.assertTrue(path.get(2).getValue().equals("G")); + Assert.assertTrue(path.get(3).getValue().equals("D")); + Assert.assertTrue(path.get(4).getValue().equals("F")); + Assert.assertTrue(path.get(5).getValue().equals("B")); + } + + @Test + public void depthFirstSearchRecursiveDirectedUnweightedGraph08() throws Exception { + List path = GraphSearch.depthFirstSearchRecursive(DirectedUnweightedGraph8, nodeH, nodeB); + Assert.assertEquals(path.size(), 6); + Assert.assertTrue(path.get(0).getValue().equals("H")); + Assert.assertTrue(path.get(1).getValue().equals("Z")); + Assert.assertTrue(path.get(2).getValue().equals("G")); + Assert.assertTrue(path.get(3).getValue().equals("D")); + Assert.assertTrue(path.get(4).getValue().equals("F")); + Assert.assertTrue(path.get(5).getValue().equals("B")); + } + + @Test + public void breadthFirstSearchDirectedUnweightedGraph08() throws Exception { + List path = GraphSearch.breadthFirstSearch(DirectedUnweightedGraph8, nodeH, nodeB); + Assert.assertEquals(path.size(), 5); + Assert.assertTrue(path.get(0).getValue().equals("H")); + Assert.assertTrue(path.get(1).getValue().equals("Z")); + Assert.assertTrue(path.get(2).getValue().equals("D")); + Assert.assertTrue(path.get(3).getValue().equals("F")); + Assert.assertTrue(path.get(4).getValue().equals("B")); + } + + @Test + public void djikstraShortestPathDirectedWeightedGraph08() throws Exception { + List path = GraphSearch.djikstraShortestPath(DirectedUnweightedGraph8, nodeH, nodeB); + Assert.assertEquals(path.size(), 5); + Assert.assertTrue(path.get(0).getValue().equals("H")); + Assert.assertTrue(path.get(1).getValue().equals("Z")); + Assert.assertTrue(path.get(2).getValue().equals("D")); + Assert.assertTrue(path.get(3).getValue().equals("F")); + Assert.assertTrue(path.get(4).getValue().equals("B")); + } + + @Test + public void depthFirstSearchDirectedUnweightedGraph09() throws Exception { + List path = GraphSearch.depthFirstSearch(DirectedUnweightedGraph9, nodeE, nodeF); + Assert.assertEquals(path.size(), 5); + Assert.assertTrue(path.get(0).getValue().equals("E")); + Assert.assertTrue(path.get(1).getValue().equals("Z")); + Assert.assertTrue(path.get(2).getValue().equals("G")); + Assert.assertTrue(path.get(3).getValue().equals("D")); + Assert.assertTrue(path.get(4).getValue().equals("F")); + } + + @Test + public void depthFirstSearchRecursiveDirectedUnweightedGraph09() throws Exception { + List path = GraphSearch.depthFirstSearchRecursive(DirectedUnweightedGraph9, nodeE, nodeF); + Assert.assertEquals(path.size(), 5); + Assert.assertTrue(path.get(0).getValue().equals("E")); + Assert.assertTrue(path.get(1).getValue().equals("Z")); + Assert.assertTrue(path.get(2).getValue().equals("G")); + Assert.assertTrue(path.get(3).getValue().equals("D")); + Assert.assertTrue(path.get(4).getValue().equals("F")); + } + + @Test + public void breadthFirstSearchDirectedUnweightedGraph09() throws Exception { + List path = GraphSearch.breadthFirstSearch(DirectedUnweightedGraph9, nodeE, nodeF); + Assert.assertEquals(path.size(), 3); + Assert.assertTrue(path.get(0).getValue().equals("E")); + Assert.assertTrue(path.get(1).getValue().equals("D")); + Assert.assertTrue(path.get(2).getValue().equals("F")); + } + + @Test + public void djikstraShortestPathDirectedWeightedGraph09() throws Exception { + List path = GraphSearch.djikstraShortestPath(DirectedUnweightedGraph9, nodeE, nodeF); + Assert.assertEquals(path.size(), 3); + Assert.assertTrue(path.get(0).getValue().equals("E")); + Assert.assertTrue(path.get(1).getValue().equals("D")); + Assert.assertTrue(path.get(2).getValue().equals("F")); + } + + @Test + public void depthFirstSearchDirectedUnweightedGraph10() throws Exception { + List path = GraphSearch.depthFirstSearch(DirectedUnweightedGraph10, nodeG, nodeH); + Assert.assertEquals(path.size(), 5); + Assert.assertTrue(path.get(0).getValue().equals("G")); + Assert.assertTrue(path.get(1).getValue().equals("E")); + Assert.assertTrue(path.get(2).getValue().equals("B")); + Assert.assertTrue(path.get(3).getValue().equals("F")); + Assert.assertTrue(path.get(4).getValue().equals("H")); + } + + @Test + public void depthFirstSearchRecursiveDirectedUnweightedGraph10() throws Exception { + List path = GraphSearch.depthFirstSearchRecursive(DirectedUnweightedGraph10, nodeG, nodeH); + Assert.assertEquals(path.size(), 5); + Assert.assertTrue(path.get(0).getValue().equals("G")); + Assert.assertTrue(path.get(1).getValue().equals("E")); + Assert.assertTrue(path.get(2).getValue().equals("B")); + Assert.assertTrue(path.get(3).getValue().equals("F")); + Assert.assertTrue(path.get(4).getValue().equals("H")); + } + + @Test + public void breadthFirstSearchDirectedUnweightedGraph10() throws Exception { + List path = GraphSearch.breadthFirstSearch(DirectedUnweightedGraph10, nodeG, nodeH); + Assert.assertEquals(path.size(), 5); + Assert.assertTrue(path.get(0).getValue().equals("G")); + Assert.assertTrue(path.get(1).getValue().equals("E")); + Assert.assertTrue(path.get(2).getValue().equals("B")); + Assert.assertTrue(path.get(3).getValue().equals("F")); + Assert.assertTrue(path.get(4).getValue().equals("H")); + } + + @Test + public void djikstraShortestPathDirectedWeightedGraph10() throws Exception { + List path = GraphSearch.djikstraShortestPath(DirectedUnweightedGraph10, nodeG, nodeH); + Assert.assertEquals(path.size(), 5); + Assert.assertTrue(path.get(0).getValue().equals("G")); + Assert.assertTrue(path.get(1).getValue().equals("E")); + Assert.assertTrue(path.get(2).getValue().equals("B")); + Assert.assertTrue(path.get(3).getValue().equals("F")); + Assert.assertTrue(path.get(4).getValue().equals("H")); + } + +} \ No newline at end of file diff --git a/src/test/java/graphs/DirectedWeightedGraphTest.java b/src/test/java/graphs/DirectedWeightedGraphTest.java new file mode 100644 index 0000000..3b26b07 --- /dev/null +++ b/src/test/java/graphs/DirectedWeightedGraphTest.java @@ -0,0 +1,317 @@ +package graphs; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; + +public class DirectedWeightedGraphTest { + + private Node nodeA; + private Node nodeB; + private Node nodeC; + private Node nodeD; + private Node nodeE; + private Node nodeF; + private Node nodeG; + private Node nodeH; + private Node nodeZ; + + private Graph DirectedWeightedGraph11, + DirectedWeightedGraph12, + DirectedWeightedGraph13; + + + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Before + public void setUp() throws Exception { + nodeA = new Node("A"); + nodeB = new Node("B"); + nodeC = new Node("C"); + nodeD = new Node("D"); + nodeE = new Node("E"); + nodeF = new Node("F"); + nodeG = new Node("G"); + nodeH = new Node("H"); + nodeZ = new Node("Z"); + + + List nodesForUndirectedUnweightedGraph2 = new LinkedList(Arrays.asList( + nodeA, + nodeB, + nodeC, + nodeD, + nodeE, + nodeF, + nodeG, + nodeH, + nodeZ + )); + Edge edgeBetweenAandB = new Edge(nodeA,nodeB); + Edge edgeBetweenBandC = new Edge(nodeB,nodeC); + Edge edgeBetweenHandZ = new Edge(nodeH,nodeZ); + Edge edgeBetweenEandZ = new Edge(nodeE,nodeZ); + Edge edgeBetweenDandF = new Edge(nodeD,nodeF); + Edge edgeBetweenBandD = new Edge(nodeB,nodeD); + Edge edgeBetweenAandD = new Edge(nodeA,nodeD); + Edge edgeBetweenBandH = new Edge(nodeB,nodeH); + Edge edgeBetweenCandE = new Edge(nodeC,nodeE); + Edge edgeBetweenBandF = new Edge(nodeB,nodeF); + Edge edgeBetweenAandC = new Edge(nodeA,nodeC); + Edge edgeBetweenFandH = new Edge(nodeF,nodeH); + Edge edgeBetweenGandD = new Edge(nodeG,nodeD); + Edge edgeBetweenZandG = new Edge(nodeZ,nodeG); + Edge edgeBetweenZandD = new Edge(nodeZ,nodeD); + Edge edgeBetweenFandB = new Edge(nodeF,nodeB); + Edge edgeBetweenDandC = new Edge(nodeD,nodeC); + Edge edgeBetweenEandD = new Edge(nodeE,nodeD); + Edge edgeBetweenGandA = new Edge(nodeG,nodeA); + Edge edgeBetweenFandA = new Edge(nodeF,nodeA); + Edge edgeBetweenZandC = new Edge(nodeZ,nodeC); + Edge edgeBetweenGandE = new Edge(nodeG,nodeE); + Edge edgeBetweenEandB = new Edge(nodeE,nodeB); + Edge edgeBetweenDandZ = new Edge(nodeD,nodeZ); + + + /* + * graph 8 but weighted + * 12 edges + * a-d + * b-d + * g-d + * z-g + * z-d 2, rest 1 + * h-z + * b-h + * f-b + * c-e + * d-c + * e-d + * d-f + * + * + */ + List edgesForGraph11 = new LinkedList(); + edgesForGraph11.add(edgeBetweenAandD.setWeight(1)); + edgesForGraph11.add(edgeBetweenZandD.setWeight(2)); + edgesForGraph11.add(edgeBetweenBandD.setWeight(1)); + edgesForGraph11.add(edgeBetweenHandZ.setWeight(1)); + edgesForGraph11.add(edgeBetweenBandH.setWeight(1)); + edgesForGraph11.add(edgeBetweenCandE.setWeight(1)); + edgesForGraph11.add(edgeBetweenGandD.setWeight(1)); + edgesForGraph11.add(edgeBetweenZandG.setWeight(1)); + edgesForGraph11.add(edgeBetweenFandB.setWeight(1)); + edgesForGraph11.add(edgeBetweenDandC.setWeight(1)); + edgesForGraph11.add(edgeBetweenEandD.setWeight(1)); + edgesForGraph11.add(edgeBetweenDandF.setWeight(1)); + DirectedWeightedGraph11 = new Graph(nodesForUndirectedUnweightedGraph2, edgesForGraph11, true); + DirectedWeightedGraph11.setWeighted(true); + + // + // Graph #11: directed and weighted + // + + /* + * graph 9 but weighted + * 12 edges + * a-b + * b-c + * c-e + * e-d + * g-d + * g-a + * z-g + * h-z + * f-h + * d-f + * e-z + * f-a + * + */ + List edgesForGraph12 = new LinkedList(); + edgesForGraph12.add(edgeBetweenAandB.setWeight(1)); + edgesForGraph12.add(edgeBetweenBandC.setWeight(1)); + edgesForGraph12.add(edgeBetweenCandE.setWeight(1)); + edgesForGraph12.add(edgeBetweenEandZ.setWeight(1)); + edgesForGraph12.add(edgeBetweenEandD.setWeight(2)); + edgesForGraph12.add(edgeBetweenGandD.setWeight(2)); + edgesForGraph12.add(edgeBetweenZandG.setWeight(1)); + edgesForGraph12.add(edgeBetweenHandZ.setWeight(1)); + edgesForGraph12.add(edgeBetweenFandH.setWeight(1)); + edgesForGraph12.add(edgeBetweenDandF.setWeight(1)); + edgesForGraph12.add(edgeBetweenGandA.setWeight(1)); + edgesForGraph12.add(edgeBetweenFandA.setWeight(1)); + DirectedWeightedGraph12 = new Graph(nodesForUndirectedUnweightedGraph2, edgesForGraph12, true); + DirectedWeightedGraph12.setWeighted(true); + + // + // Graph #12: directed and weighted + // + + + /* + * graph 10 but weighted + * 10 edges + * a-d + * a-c + * d-c + * z-c + * g-e + * e-b + * b-f + * f-h + * d-z + * g-a + * + */ + + List edgesForGraph13 = new LinkedList(); + edgesForGraph13.add(edgeBetweenAandD.setWeight(1)); + edgesForGraph13.add(edgeBetweenAandC.setWeight(1)); + edgesForGraph13.add(edgeBetweenDandC.setWeight(1)); + edgesForGraph13.add(edgeBetweenBandF.setWeight(1)); + edgesForGraph13.add(edgeBetweenFandH.setWeight(1)); + edgesForGraph13.add(edgeBetweenZandC.setWeight(1)); + edgesForGraph13.add(edgeBetweenGandE.setWeight(2)); + edgesForGraph13.add(edgeBetweenEandB.setWeight(1)); + edgesForGraph13.add(edgeBetweenDandZ.setWeight(1)); + edgesForGraph13.add(edgeBetweenGandA.setWeight(1)); + + + DirectedWeightedGraph13 = new Graph(nodesForUndirectedUnweightedGraph2, edgesForGraph13, true); + DirectedWeightedGraph13.setWeighted(true); + + // + // Graph #13: directed and weighted + // + + + } + + @Test + public void depthFirstSearchDirectedWeightedGraph11() throws Exception { + List path = GraphSearch.depthFirstSearch(DirectedWeightedGraph11, nodeH, nodeB); + Assert.assertEquals(path.size(), 6); + Assert.assertTrue(path.get(0).getValue().equals("H")); + Assert.assertTrue(path.get(1).getValue().equals("Z")); + Assert.assertTrue(path.get(2).getValue().equals("G")); + Assert.assertTrue(path.get(3).getValue().equals("D")); + Assert.assertTrue(path.get(4).getValue().equals("F")); + Assert.assertTrue(path.get(5).getValue().equals("B")); + } + + @Test + public void depthFirstSearchRecursiveDirectedWeightedGraph11() throws Exception { + List path = GraphSearch.depthFirstSearchRecursive(DirectedWeightedGraph11, nodeH, nodeB); + Assert.assertEquals(path.size(), 6); + Assert.assertTrue(path.get(0).getValue().equals("H")); + Assert.assertTrue(path.get(1).getValue().equals("Z")); + Assert.assertTrue(path.get(2).getValue().equals("G")); + Assert.assertTrue(path.get(3).getValue().equals("D")); + Assert.assertTrue(path.get(4).getValue().equals("F")); + Assert.assertTrue(path.get(5).getValue().equals("B")); + } + + @Test + public void breadthFirstSearchDirectedWeightedGraph11() throws Exception { + List path = GraphSearch.breadthFirstSearch(DirectedWeightedGraph11, nodeH, nodeB); + Assert.assertEquals(path.size(), 5); + Assert.assertTrue(path.get(0).getValue().equals("H")); + Assert.assertTrue(path.get(1).getValue().equals("Z")); + Assert.assertTrue(path.get(2).getValue().equals("D")); + Assert.assertTrue(path.get(3).getValue().equals("F")); + Assert.assertTrue(path.get(4).getValue().equals("B")); + } + + @Test + public void djikstraShortestPathDirectedWeightedGraph11() throws Exception { + List path = GraphSearch.djikstraShortestPath(DirectedWeightedGraph11, nodeH, nodeB); + Assert.assertEquals(path.size(), 5); + } + + @Test + public void depthFirstSearchDirectedWeightedGraph12() throws Exception { + List path = GraphSearch.depthFirstSearch(DirectedWeightedGraph12, nodeE, nodeF); + Assert.assertEquals(path.size(), 5); + Assert.assertTrue(path.get(0).getValue().equals("E")); + Assert.assertTrue(path.get(1).getValue().equals("Z")); + Assert.assertTrue(path.get(2).getValue().equals("G")); + Assert.assertTrue(path.get(3).getValue().equals("D")); + Assert.assertTrue(path.get(4).getValue().equals("F")); + } + + @Test + public void depthFirstSearchRecursiveDirectedWeightedGraph12() throws Exception { + List path = GraphSearch.depthFirstSearchRecursive(DirectedWeightedGraph12, nodeE, nodeF); + Assert.assertEquals(path.size(), 5); + Assert.assertTrue(path.get(0).getValue().equals("E")); + Assert.assertTrue(path.get(1).getValue().equals("Z")); + Assert.assertTrue(path.get(2).getValue().equals("G")); + Assert.assertTrue(path.get(3).getValue().equals("D")); + Assert.assertTrue(path.get(4).getValue().equals("F")); + } + + @Test + public void breadthFirstSearchDirectedWeightedGraph12() throws Exception { + List path = GraphSearch.breadthFirstSearch(DirectedWeightedGraph12, nodeE, nodeF); + Assert.assertEquals(path.size(), 3); + Assert.assertTrue(path.get(0).getValue().equals("E")); + Assert.assertTrue(path.get(1).getValue().equals("D")); + Assert.assertTrue(path.get(2).getValue().equals("F")); + } + + @Test + public void djikstraShortestPathDirectedWeightedGraph12() throws Exception { + List path = GraphSearch.djikstraShortestPath(DirectedWeightedGraph12, nodeE, nodeF); + Assert.assertEquals(path.size(), 3); + } + + @Test + public void depthFirstSearchDirectedWeightedGraph13() throws Exception { + List path = GraphSearch.depthFirstSearch(DirectedWeightedGraph13, nodeG, nodeH); + Assert.assertEquals(path.size(), 5); + Assert.assertTrue(path.get(0).getValue().equals("G")); + Assert.assertTrue(path.get(1).getValue().equals("E")); + Assert.assertTrue(path.get(2).getValue().equals("B")); + Assert.assertTrue(path.get(3).getValue().equals("F")); + Assert.assertTrue(path.get(4).getValue().equals("H")); + } + + @Test + public void depthFirstSearchRecursiveDirectedWeightedGraph13() throws Exception { + List path = GraphSearch.depthFirstSearchRecursive(DirectedWeightedGraph13, nodeG, nodeH); + Assert.assertEquals(path.size(), 5); + Assert.assertTrue(path.get(0).getValue().equals("G")); + Assert.assertTrue(path.get(1).getValue().equals("E")); + Assert.assertTrue(path.get(2).getValue().equals("B")); + Assert.assertTrue(path.get(3).getValue().equals("F")); + Assert.assertTrue(path.get(4).getValue().equals("H")); + } + + @Test + public void breadthFirstSearchDirectedWeightedGraph13() throws Exception { + List path = GraphSearch.breadthFirstSearch(DirectedWeightedGraph13, nodeG, nodeH); + Assert.assertEquals(path.size(), 5); + Assert.assertTrue(path.get(0).getValue().equals("G")); + Assert.assertTrue(path.get(1).getValue().equals("E")); + Assert.assertTrue(path.get(2).getValue().equals("B")); + Assert.assertTrue(path.get(3).getValue().equals("F")); + Assert.assertTrue(path.get(4).getValue().equals("H")); + } + + @Test + public void djikstraShortestPathDirectedWeightedGraph13() throws Exception { + List path = GraphSearch.djikstraShortestPath(DirectedWeightedGraph13, nodeG, nodeH); + Assert.assertEquals(path.size(), 5); + } + + +} \ No newline at end of file diff --git a/src/test/java/graphs/GraphSearchTest.java b/src/test/java/graphs/GraphSearchTest.java index cd52b65..add916d 100644 --- a/src/test/java/graphs/GraphSearchTest.java +++ b/src/test/java/graphs/GraphSearchTest.java @@ -491,7 +491,7 @@ public void setUp() throws Exception { // // Graph #11: directed and weighted // - + /* * graph 9 but weighted * 12 edges @@ -528,8 +528,8 @@ public void setUp() throws Exception { // // Graph #12: directed and weighted // - - + + /* * graph 10 but weighted * 10 edges @@ -558,7 +558,7 @@ public void setUp() throws Exception { edgesForGraph13.add(edgeBetweenDandZ.setWeight(1)); edgesForGraph13.add(edgeBetweenGandA.setWeight(1)); - + DirectedWeightedGraph13 = new Graph(nodesForUndirectedUnweightedGraph2, edgesForGraph13, true); DirectedWeightedGraph13.setWeighted(true); diff --git a/src/test/java/graphs/GraphTestSuite.java b/src/test/java/graphs/GraphTestSuite.java new file mode 100644 index 0000000..50a3266 --- /dev/null +++ b/src/test/java/graphs/GraphTestSuite.java @@ -0,0 +1,18 @@ +package graphs; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +@RunWith(Suite.class) +@SuiteClasses({ + SpecialGraphTest.class, + UndirectedUnweightedGraphTest.class, + UndirectedWeightedGraphTest.class, + DirectedUnweightedGraphTest.class, + DirectedWeightedGraphTest.class +}) + +public class GraphTestSuite { + +} diff --git a/src/test/java/graphs/SpecialGraphTest.java b/src/test/java/graphs/SpecialGraphTest.java new file mode 100644 index 0000000..a672d2c --- /dev/null +++ b/src/test/java/graphs/SpecialGraphTest.java @@ -0,0 +1,219 @@ +package graphs; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; + +public class SpecialGraphTest { + + private Node nodeA; + private Node nodeB; + private Node nodeC; + private Node nodeD; + private Node nodeE; + private Node nodeF; + private Node nodeG; + private Node nodeH; + private Node nodeZ; + + private Graph UndirectedUnweightedgraph1, + UndirectedUnweightedgraph5; + + + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Before + public void setUp() throws Exception { + nodeA = new Node("A"); + nodeB = new Node("B"); + nodeC = new Node("C"); + nodeD = new Node("D"); + nodeE = new Node("E"); + nodeF = new Node("F"); + nodeG = new Node("G"); + nodeH = new Node("H"); + nodeZ = new Node("Z"); + + List nodesForUndirectedUnweightedGraph1 = new LinkedList(Arrays.asList( + nodeA, + nodeB, + nodeC, + nodeD, + nodeE, + nodeF + )); + + Edge edgeBetweenAandB = new Edge(nodeA, nodeB); + Edge edgeBetweenBandC = new Edge(nodeB, nodeC); + Edge edgeBetweenCandD = new Edge(nodeC, nodeD); + Edge edgeBetweenDandE = new Edge(nodeD, nodeE); + Edge edgeBetweenEandF = new Edge(nodeE, nodeF); + + List edgesForUndirectedUnweightedGraph1 = new LinkedList(); + edgesForUndirectedUnweightedGraph1.add(edgeBetweenAandB); + edgesForUndirectedUnweightedGraph1.add(edgeBetweenBandC); + edgesForUndirectedUnweightedGraph1.add(edgeBetweenCandD); + edgesForUndirectedUnweightedGraph1.add(edgeBetweenDandE); + edgesForUndirectedUnweightedGraph1.add(edgeBetweenEandF); + // + // Graph #1: Straight line (unweighted, undirected) + // A -> B -> C -> D -> E -> F + // + UndirectedUnweightedgraph1 = new Graph(nodesForUndirectedUnweightedGraph1, edgesForUndirectedUnweightedGraph1); + + + List nodesForUndirectedUnweightedGraph5 = new LinkedList(Arrays.asList( + nodeA, + nodeB, + nodeC, + nodeD, + nodeE, + nodeF, + nodeG, + nodeH, + nodeZ + )); + + // + // Graph #5: graph with nodes from graph 2 and edges from graph 1 + // + // start and target have no path, will return empty list + UndirectedUnweightedgraph5 = new Graph(nodesForUndirectedUnweightedGraph5, edgesForUndirectedUnweightedGraph1); + + + + } + + @Test + public void depthFirstSearchNullStartNode() throws Exception { + thrown.expect(IllegalArgumentException.class); + List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph5, null, nodeZ); + // the expect message is thrown if the thrown var doesnt catch it's appropriate exception? + // ie this message doesn't need to match the message of the thrown exception in GraphSearch.java, correct? + thrown.expectMessage("expect message"); + } + + @Test + public void depthFirstSearchRecursiveNullStartNode() throws Exception { + thrown.expect(IllegalArgumentException.class); + List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph5, null, nodeZ); + thrown.expectMessage("expect message"); + } + + @Test + public void breadthFirstSearchNullStartNode() throws Exception { + thrown.expect(IllegalArgumentException.class); + List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph5, null, nodeZ); + thrown.expectMessage("expect message"); + } + + @Test + public void depthFirstSearchNullFinishNode() throws Exception { + thrown.expect(IllegalArgumentException.class); + List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph5, nodeA, null); + // the expect message is thrown if the thrown var doesnt catch it's appropriate exception? + // ie this message doesn't need to match the message of the thrown exception in GraphSearch.java, correct? + thrown.expectMessage("expect message"); + } + + @Test + public void depthFirstSearchRecursiveNullFinishNode() throws Exception { + thrown.expect(IllegalArgumentException.class); + List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph5, nodeA, null); + thrown.expectMessage("expect message"); + } + + @Test + public void breadthFirstSearchNullFinishNode() throws Exception { + thrown.expect(IllegalArgumentException.class); + List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph5, nodeA, null); + thrown.expectMessage("expect message"); + } + + @Test + public void depthFirstSearchOutFinishNode() throws Exception { + List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph1, nodeA, nodeZ); + Assert.assertEquals(path.size(), 0); + } + + @Test + public void depthFirstSearchRecursiveOutFinishNode() throws Exception { + List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph1, nodeA, nodeZ); + Assert.assertEquals(path.size(), 0); + } + + @Test + public void breadthFirstSearchOutFinishNode() throws Exception { + List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph1, nodeA, nodeZ); + Assert.assertEquals(path.size(), 0); + } + + @Test + public void depthFirstSearchOutStartNode() throws Exception { + List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph1, nodeZ, nodeA); + Assert.assertEquals(path.size(), 0); + } + + @Test + public void depthFirstSearchRecursiveOutStartNode() throws Exception { + List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph1, nodeZ, nodeA); + Assert.assertEquals(path.size(), 0); + } + + @Test + public void breadthFirstSearchOutStartNode() throws Exception { + List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph1, nodeZ, nodeA); + Assert.assertEquals(path.size(), 0); + } + + @Test + public void depthFirstSearchNullGraph() throws Exception { + thrown.expect(IllegalArgumentException.class); + List path = GraphSearch.depthFirstSearch(null, nodeA, nodeZ); + thrown.expectMessage("expect message"); + } + + @Test + public void depthFirstSearchRecursiveNullGraph() throws Exception { + thrown.expect(IllegalArgumentException.class); + List path = GraphSearch.depthFirstSearchRecursive(null, nodeA, nodeZ); + thrown.expectMessage("expect message"); + } + + @Test + public void breadthFirstSearchNullGraph() throws Exception { + thrown.expect(IllegalArgumentException.class); + List path = GraphSearch.breadthFirstSearch(null, nodeA, nodeZ); + thrown.expectMessage("expect message"); + } + + @Test + public void depthFirstSearchEmptyGraph() throws Exception { + thrown.expect(IllegalArgumentException.class); + List path = GraphSearch.depthFirstSearch(new Graph(), nodeA, nodeZ); + thrown.expectMessage("expect message"); + } + + @Test + public void depthFirstSearchRecursiveEmptyGraph() throws Exception { + thrown.expect(IllegalArgumentException.class); + List path = GraphSearch.depthFirstSearchRecursive(new Graph(), nodeA, nodeZ); + thrown.expectMessage("expect message"); + } + + @Test + public void breadthFirstSearchEmptyGraph() throws Exception { + thrown.expect(IllegalArgumentException.class); + List path = GraphSearch.breadthFirstSearch(new Graph(), nodeA, nodeZ); + thrown.expectMessage("expect message"); + } + +} \ No newline at end of file diff --git a/src/test/java/graphs/UndirectedUnweightedGraphTest.java b/src/test/java/graphs/UndirectedUnweightedGraphTest.java new file mode 100644 index 0000000..0823866 --- /dev/null +++ b/src/test/java/graphs/UndirectedUnweightedGraphTest.java @@ -0,0 +1,574 @@ +package graphs; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; + +public class UndirectedUnweightedGraphTest { + + private Node nodeA; + private Node nodeB; + private Node nodeC; + private Node nodeD; + private Node nodeE; + private Node nodeF; + private Node nodeG; + private Node nodeH; + private Node nodeZ; + + private Graph UndirectedUnweightedGraph1, + UndirectedUnweightedGraph2, + UndirectedUnweightedGraph3, + UndirectedUnweightedGraph4, + UndirectedUnweightedGraph5, + UndirectedUnweightedGraph6, + UndirectedUnweightedGraph7; + + + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Before + public void setUp() throws Exception { + nodeA = new Node("A"); + nodeB = new Node("B"); + nodeC = new Node("C"); + nodeD = new Node("D"); + nodeE = new Node("E"); + nodeF = new Node("F"); + nodeG = new Node("G"); + nodeH = new Node("H"); + nodeZ = new Node("Z"); + + List nodesForUndirectedUnweightedGraph1 = new LinkedList(Arrays.asList( + nodeA, + nodeB, + nodeC, + nodeD, + nodeE, + nodeF + )); + + Edge edgeBetweenAandB = new Edge(nodeA, nodeB); + Edge edgeBetweenBandC = new Edge(nodeB, nodeC); + Edge edgeBetweenCandD = new Edge(nodeC, nodeD); + Edge edgeBetweenDandE = new Edge(nodeD, nodeE); + Edge edgeBetweenEandF = new Edge(nodeE, nodeF); + + List edgesForUndirectedUnweightedGraph1 = new LinkedList(); + edgesForUndirectedUnweightedGraph1.add(edgeBetweenAandB); + edgesForUndirectedUnweightedGraph1.add(edgeBetweenBandC); + edgesForUndirectedUnweightedGraph1.add(edgeBetweenCandD); + edgesForUndirectedUnweightedGraph1.add(edgeBetweenDandE); + edgesForUndirectedUnweightedGraph1.add(edgeBetweenEandF); + // + // Graph #1: Straight line (unweighted, undirected) + // A -> B -> C -> D -> E -> F + // + UndirectedUnweightedGraph1 = new Graph(nodesForUndirectedUnweightedGraph1, edgesForUndirectedUnweightedGraph1); + + + List nodesForUndirectedUnweightedGraph2 = new LinkedList(Arrays.asList( + nodeA, + nodeB, + nodeC, + nodeD, + nodeE, + nodeF, + nodeG, + nodeH, + nodeZ + )); + + Edge edgeBetweenFandG = new Edge(nodeF, nodeG); + Edge edgeBetweenGandH = new Edge(nodeG, nodeH); + Edge edgeBetweenAandZ = new Edge(nodeA, nodeZ); + Edge edgeBetweenHandZ = new Edge(nodeH, nodeZ); + + List edgesForUndirectedUnweightedGraph2 = new LinkedList(); + edgesForUndirectedUnweightedGraph2.add(edgeBetweenAandB); + edgesForUndirectedUnweightedGraph2.add(edgeBetweenBandC); + edgesForUndirectedUnweightedGraph2.add(edgeBetweenCandD); + edgesForUndirectedUnweightedGraph2.add(edgeBetweenDandE); + edgesForUndirectedUnweightedGraph2.add(edgeBetweenEandF); + edgesForUndirectedUnweightedGraph2.add(edgeBetweenFandG); + edgesForUndirectedUnweightedGraph2.add(edgeBetweenGandH); + edgesForUndirectedUnweightedGraph2.add(edgeBetweenAandZ); + edgesForUndirectedUnweightedGraph2.add(edgeBetweenHandZ); + + // + // Graph #2: Different solutions for DFS and BFS (unweighted, undirected) + // A -> B -> C -> D -> E -> F -> G -> H + // \ / + // \------------> Z -------------/ + // + UndirectedUnweightedGraph2 = new Graph(nodesForUndirectedUnweightedGraph2, edgesForUndirectedUnweightedGraph2); + + + + // graph 2 has all nodes A - H & Z + List nodesForUndirectedUnweightedGraph3 = nodesForUndirectedUnweightedGraph2; + +// Edge edgeBetweenHandZ = new Edge(nodeZ, nodeH); + /* + * make edges, then make edge list: + * graph 3 has edges: + * A - D + * B - D + * B - C ~ + * C - D ~ + * D - F + * D - H + * H - Z ~ + * E - Z + * E - G + */ + + Edge edgeBetweenEandZ = new Edge(nodeE, nodeZ); + Edge edgeBetweenEandG = new Edge(nodeE, nodeG); + Edge edgeBetweenDandH = new Edge(nodeD, nodeH); + Edge edgeBetweenDandF = new Edge(nodeD, nodeF); + Edge edgeBetweenBandD = new Edge(nodeB, nodeD); + Edge edgeBetweenAandD = new Edge(nodeA, nodeD); + + List edgesForUndirectedUnweightedGraph3 = new LinkedList(); + edgesForUndirectedUnweightedGraph3.add(edgeBetweenBandC); + edgesForUndirectedUnweightedGraph3.add(edgeBetweenCandD); + edgesForUndirectedUnweightedGraph3.add(edgeBetweenHandZ); + edgesForUndirectedUnweightedGraph3.add(edgeBetweenEandZ); + edgesForUndirectedUnweightedGraph3.add(edgeBetweenEandG); + edgesForUndirectedUnweightedGraph3.add(edgeBetweenDandH); + edgesForUndirectedUnweightedGraph3.add(edgeBetweenDandF); + edgesForUndirectedUnweightedGraph3.add(edgeBetweenBandD); + edgesForUndirectedUnweightedGraph3.add(edgeBetweenAandD); + + // + // Graph #3: see UndirectedUnweightedGraph3.png + // + UndirectedUnweightedGraph3 = new Graph(nodesForUndirectedUnweightedGraph3, edgesForUndirectedUnweightedGraph3); + + + + // graph 2 has all nodes A - H & Z + List nodesForUndirectedUnweightedGraph4 = nodesForUndirectedUnweightedGraph2; + +// Edge edgeBetweenHandZ = new Edge(nodeZ, nodeH); + /* + * make edges, then make edge list: + * graph 4 has edges: + * a-b ~ + * b-e + * b-h + * e-g ~ + * g-h ~ + * h-z ~ + * h-d ~ + * d-f ~ + * d-c ~ + * c-f + * + */ + Edge edgeBetweenBandE = new Edge(nodeB, nodeE); + Edge edgeBetweenBandH = new Edge(nodeB, nodeH); + Edge edgeBetweenCandF = new Edge(nodeC, nodeF); + + + List edgesForUndirectedUnweightedGraph4 = new LinkedList(); + edgesForUndirectedUnweightedGraph4.add(edgeBetweenCandD); + edgesForUndirectedUnweightedGraph4.add(edgeBetweenHandZ); + edgesForUndirectedUnweightedGraph4.add(edgeBetweenEandG); + edgesForUndirectedUnweightedGraph4.add(edgeBetweenDandH); + edgesForUndirectedUnweightedGraph4.add(edgeBetweenDandF); + edgesForUndirectedUnweightedGraph4.add(edgeBetweenAandB); + edgesForUndirectedUnweightedGraph4.add(edgeBetweenGandH); + edgesForUndirectedUnweightedGraph4.add(edgeBetweenBandE); + edgesForUndirectedUnweightedGraph4.add(edgeBetweenBandH); + edgesForUndirectedUnweightedGraph4.add(edgeBetweenCandF); + + + // + // Graph #4: see UndirectedUnweightedGraph4.png + // + UndirectedUnweightedGraph4 = new Graph(nodesForUndirectedUnweightedGraph4, edgesForUndirectedUnweightedGraph4); + + + // graph 2 has all nodes A - H & Z + List nodesForUndirectedUnweightedGraph5 = nodesForUndirectedUnweightedGraph2; + // + // Graph #5: graph with nodes from graph 2 and edges from graph 1 + // + // start and target have no path, will return empty list + UndirectedUnweightedGraph5 = new Graph(nodesForUndirectedUnweightedGraph5, edgesForUndirectedUnweightedGraph1); + + + + // graph 2 has all nodes A - H & Z + List nodesForUndirectedUnweightedGraph6 = nodesForUndirectedUnweightedGraph2; + /* + * make edges, then make edge list: + * graph 6 nodes A-F, and all edges (15) + * a-b ~ + * a-c + * a-d ~ + * a-e + * a-f + * b-c ~ + * b-d ~ + * b-e ~ + * b-f + * c-d ~ + * c-e + * c-f ~ + * d-e ~ + * d-f ~ + * e-f ~ + * + */ + + Edge edgeBetweenCandE = new Edge(nodeC, nodeE); + Edge edgeBetweenBandF = new Edge(nodeB, nodeF); + Edge edgeBetweenAandF = new Edge(nodeA, nodeF); + Edge edgeBetweenAandE = new Edge(nodeA, nodeE); + Edge edgeBetweenAandC = new Edge(nodeA, nodeC); + + + List edgesForUndirectedUnweightedGraph6 = new LinkedList(edgesForUndirectedUnweightedGraph1); + edgesForUndirectedUnweightedGraph6.add(edgeBetweenCandF); + edgesForUndirectedUnweightedGraph6.add(edgeBetweenAandB); + edgesForUndirectedUnweightedGraph6.add(edgeBetweenAandD); + edgesForUndirectedUnweightedGraph6.add(edgeBetweenBandC); + edgesForUndirectedUnweightedGraph6.add(edgeBetweenBandD); + edgesForUndirectedUnweightedGraph6.add(edgeBetweenBandE); + edgesForUndirectedUnweightedGraph6.add(edgeBetweenCandD); + edgesForUndirectedUnweightedGraph6.add(edgeBetweenCandE); + edgesForUndirectedUnweightedGraph6.add(edgeBetweenDandE); + edgesForUndirectedUnweightedGraph6.add(edgeBetweenDandF); + edgesForUndirectedUnweightedGraph6.add(edgeBetweenEandF); + edgesForUndirectedUnweightedGraph6.add(edgeBetweenBandF); + edgesForUndirectedUnweightedGraph6.add(edgeBetweenAandF); + edgesForUndirectedUnweightedGraph6.add(edgeBetweenAandE); + edgesForUndirectedUnweightedGraph6.add(edgeBetweenAandC); + + // + // Graph #6: graph with nodes from graph 1, fully connected + // + UndirectedUnweightedGraph6 = new Graph(nodesForUndirectedUnweightedGraph6, edgesForUndirectedUnweightedGraph6); + + + + // graph 2 has all nodes A - H & Z + List nodesForUndirectedUnweightedGraph7 = nodesForUndirectedUnweightedGraph2; + // edges needed (17): + /* + * a-b ~ + * a-e ~ + * a-z ~ + * a-g + * b-g + * b-e ~ + * e-g ~ + * g-z + * e-z ~ + * d-e ~ + * h-z ~ + * d-h ~ + * c-d ~ + * d-f ~ + * c-h + * c-f ~ + * f-h + * + */ + + + Edge edgeBetweenCandH = new Edge(nodeC, nodeH); + Edge edgeBetweenBandG = new Edge(nodeB, nodeG); + Edge edgeBetweenAandG = new Edge(nodeA, nodeG); + Edge edgeBetweenGandZ = new Edge(nodeG, nodeZ); + Edge edgeBetweenFandH = new Edge(nodeF, nodeH); + + List edgesForUndirectedUnweightedGraph7 = new LinkedList(); + edgesForUndirectedUnweightedGraph7.add(edgeBetweenAandB); + edgesForUndirectedUnweightedGraph7.add(edgeBetweenAandE); + edgesForUndirectedUnweightedGraph7.add(edgeBetweenAandZ); + edgesForUndirectedUnweightedGraph7.add(edgeBetweenBandE); + edgesForUndirectedUnweightedGraph7.add(edgeBetweenCandD); + edgesForUndirectedUnweightedGraph7.add(edgeBetweenCandF); + edgesForUndirectedUnweightedGraph7.add(edgeBetweenDandE); + edgesForUndirectedUnweightedGraph7.add(edgeBetweenDandF); + edgesForUndirectedUnweightedGraph7.add(edgeBetweenDandH); + edgesForUndirectedUnweightedGraph7.add(edgeBetweenEandG); + edgesForUndirectedUnweightedGraph7.add(edgeBetweenEandZ); + edgesForUndirectedUnweightedGraph7.add(edgeBetweenHandZ); + edgesForUndirectedUnweightedGraph7.add(edgeBetweenCandH); + edgesForUndirectedUnweightedGraph7.add(edgeBetweenBandG); + edgesForUndirectedUnweightedGraph7.add(edgeBetweenAandG); + edgesForUndirectedUnweightedGraph7.add(edgeBetweenGandZ); + edgesForUndirectedUnweightedGraph7.add(edgeBetweenFandH); + // + // Graph #7: graph7.png + // + UndirectedUnweightedGraph7 = new Graph(nodesForUndirectedUnweightedGraph7, edgesForUndirectedUnweightedGraph7); + + + + } + + @Test + public void depthFirstSearchUndirectedUnweightedGraph01() throws Exception { + List path = GraphSearch.depthFirstSearch(UndirectedUnweightedGraph1, nodeA, nodeF); + Assert.assertEquals(path.size(), 6); + Assert.assertTrue(path.get(0).getValue().equals("A")); + Assert.assertTrue(path.get(1).getValue().equals("B")); + Assert.assertTrue(path.get(2).getValue().equals("C")); + Assert.assertTrue(path.get(3).getValue().equals("D")); + Assert.assertTrue(path.get(4).getValue().equals("E")); + Assert.assertTrue(path.get(5).getValue().equals("F")); + } + + @Test + public void depthFirstSearchRecursiveUndirectedUnweightedGraph01() throws Exception { + List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedGraph1, nodeA, nodeF); + Assert.assertEquals(path.size(), 6); + Assert.assertTrue(path.get(0).getValue().equals("A")); + Assert.assertTrue(path.get(1).getValue().equals("B")); + Assert.assertTrue(path.get(2).getValue().equals("C")); + Assert.assertTrue(path.get(3).getValue().equals("D")); + Assert.assertTrue(path.get(4).getValue().equals("E")); + Assert.assertTrue(path.get(5).getValue().equals("F")); + } + + @Test + public void djikstraShortestPathUndirectedUnweightedGraph01() throws Exception { + List path = GraphSearch.djikstraShortestPath(UndirectedUnweightedGraph1, nodeA, nodeF); + Assert.assertEquals(path.size(), 5); + } + + @Test + public void breadthFirstSearchUndirectedUnweightedGraph01() throws Exception { + List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedGraph1, nodeA, nodeF); + Assert.assertEquals(path.size(), 6); + Assert.assertTrue(path.get(0).getValue().equals("A")); + Assert.assertTrue(path.get(1).getValue().equals("B")); + Assert.assertTrue(path.get(2).getValue().equals("C")); + Assert.assertTrue(path.get(3).getValue().equals("D")); + Assert.assertTrue(path.get(4).getValue().equals("E")); + Assert.assertTrue(path.get(5).getValue().equals("F")); + } + + @Test + public void depthFirstSearchUndirectedUnweightedGraph02() throws Exception { + List path = GraphSearch.depthFirstSearch(UndirectedUnweightedGraph2, nodeA, nodeH); + Assert.assertEquals(path.size(), 8); + Assert.assertTrue(path.get(0).getValue().equals("A")); + Assert.assertTrue(path.get(1).getValue().equals("B")); + Assert.assertTrue(path.get(2).getValue().equals("C")); + Assert.assertTrue(path.get(3).getValue().equals("D")); + Assert.assertTrue(path.get(4).getValue().equals("E")); + Assert.assertTrue(path.get(5).getValue().equals("F")); + Assert.assertTrue(path.get(6).getValue().equals("G")); + Assert.assertTrue(path.get(7).getValue().equals("H")); + } + + @Test + public void depthFirstSearchRecursiveUndirectedUnweightedGraph02() throws Exception { + List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedGraph2, nodeA, nodeH); + Assert.assertEquals(path.size(), 8); + Assert.assertTrue(path.get(0).getValue().equals("A")); + Assert.assertTrue(path.get(1).getValue().equals("B")); + Assert.assertTrue(path.get(2).getValue().equals("C")); + Assert.assertTrue(path.get(3).getValue().equals("D")); + Assert.assertTrue(path.get(4).getValue().equals("E")); + Assert.assertTrue(path.get(5).getValue().equals("F")); + Assert.assertTrue(path.get(6).getValue().equals("G")); + Assert.assertTrue(path.get(7).getValue().equals("H")); + } + + @Test + public void breadthFirstSearchUndirectedUnweightedGraph02() throws Exception { + List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedGraph2, nodeA, nodeH); + Assert.assertEquals(path.size(), 3); + Assert.assertTrue(path.get(0).getValue().equals("A")); + Assert.assertTrue(path.get(1).getValue().equals("Z")); + Assert.assertTrue(path.get(2).getValue().equals("H")); + } + + @Test + public void djikstraShortestPathUndirectedUnweightedGraph02() throws Exception { + List path = GraphSearch.djikstraShortestPath(UndirectedUnweightedGraph2, nodeA, nodeH); + Assert.assertEquals(path.size(), 3); + } + + + @Test + public void depthFirstSearchUndirectedUnweightedGraph03() throws Exception { + List path = GraphSearch.depthFirstSearch(UndirectedUnweightedGraph3, nodeB, nodeE); + Assert.assertEquals(path.size(), 6); + Assert.assertTrue(path.get(0).getValue().equals("B")); + Assert.assertTrue(path.get(1).getValue().equals("C")); + Assert.assertTrue(path.get(2).getValue().equals("D")); + Assert.assertTrue(path.get(3).getValue().equals("H")); + Assert.assertTrue(path.get(4).getValue().equals("Z")); + Assert.assertTrue(path.get(5).getValue().equals("E")); + } + + @Test + public void depthFirstSearchRecursiveUndirectedUnweightedGraph03() throws Exception { + List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedGraph3, nodeB, nodeE); + Assert.assertEquals(path.size(), 6); + Assert.assertTrue(path.get(0).getValue().equals("B")); + Assert.assertTrue(path.get(1).getValue().equals("C")); + Assert.assertTrue(path.get(2).getValue().equals("D")); + Assert.assertTrue(path.get(3).getValue().equals("H")); + Assert.assertTrue(path.get(4).getValue().equals("Z")); + Assert.assertTrue(path.get(5).getValue().equals("E")); + } + + @Test + public void breadthFirstSearchUndirectedUnweightedGraph03() throws Exception { + List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedGraph3, nodeB, nodeE); + Assert.assertEquals(path.size(), 5); + Assert.assertTrue(path.get(0).getValue().equals("B")); + Assert.assertTrue(path.get(1).getValue().equals("D")); + Assert.assertTrue(path.get(2).getValue().equals("H")); + Assert.assertTrue(path.get(3).getValue().equals("Z")); + Assert.assertTrue(path.get(4).getValue().equals("E")); + } + + @Test + public void djikstraShortestPathUndirectedUnweightedGraph03() throws Exception { + List path = GraphSearch.djikstraShortestPath(UndirectedUnweightedGraph3, nodeB, nodeE); + Assert.assertEquals(path.size(), 5); + } + + + @Test + public void depthFirstSearchUndirectedUnweightedGraph04() throws Exception { + List path = GraphSearch.depthFirstSearch(UndirectedUnweightedGraph4, nodeB, nodeF); + Assert.assertEquals(path.size(), 7); + Assert.assertTrue(path.get(0).getValue().equals("B")); + Assert.assertTrue(path.get(1).getValue().equals("E")); + Assert.assertTrue(path.get(2).getValue().equals("G")); + Assert.assertTrue(path.get(3).getValue().equals("H")); + Assert.assertTrue(path.get(4).getValue().equals("D")); + Assert.assertTrue(path.get(5).getValue().equals("C")); + Assert.assertTrue(path.get(6).getValue().equals("F")); + } + + @Test + public void depthFirstSearchRecursiveUndirectedUnweightedGraph04() throws Exception { + List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedGraph4, nodeB, nodeF); + Assert.assertEquals(path.size(), 7); + Assert.assertTrue(path.get(0).getValue().equals("B")); + Assert.assertTrue(path.get(1).getValue().equals("E")); + Assert.assertTrue(path.get(2).getValue().equals("G")); + Assert.assertTrue(path.get(3).getValue().equals("H")); + Assert.assertTrue(path.get(4).getValue().equals("D")); + Assert.assertTrue(path.get(5).getValue().equals("C")); + Assert.assertTrue(path.get(6).getValue().equals("F")); + } + + @Test + public void breadthFirstSearchUndirectedUnweightedGraph04() throws Exception { + List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedGraph4, nodeB, nodeF); + Assert.assertEquals(path.size(), 4); + Assert.assertTrue(path.get(0).getValue().equals("B")); + Assert.assertTrue(path.get(1).getValue().equals("H")); + Assert.assertTrue(path.get(2).getValue().equals("D")); + Assert.assertTrue(path.get(3).getValue().equals("F")); + } + + @Test + public void djikstraShortestPathUndirectedUnweightedGraph04() throws Exception { + List path = GraphSearch.djikstraShortestPath(UndirectedUnweightedGraph4, nodeB, nodeF); + Assert.assertEquals(path.size(), 4); + } + + @Test + public void depthFirstSearchUndirectedUnweightedGraph05() throws Exception { + List path = GraphSearch.depthFirstSearch(UndirectedUnweightedGraph5, nodeA, nodeZ); + Assert.assertEquals(path.size(), 0); + } + + @Test + public void depthFirstSearchRecursiveUndirectedUnweightedGraph05() throws Exception { + List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedGraph5, nodeA, nodeZ); + Assert.assertEquals(path.size(), 0); + } + + @Test + public void breadthFirstSearchUndirectedUnweightedGraph05() throws Exception { + List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedGraph5, nodeA, nodeZ); + Assert.assertEquals(path.size(), 0); + } + + @Test + public void djikstraShortestPathUndirectedUnweightedGraph05() throws Exception { + List path = GraphSearch.djikstraShortestPath(UndirectedUnweightedGraph5, nodeA, nodeZ); + Assert.assertEquals(path.size(), 0); + } + + @Test + public void depthFirstSearchUndirectedUnweightedGraph06() throws Exception { + List path = GraphSearch.depthFirstSearch(UndirectedUnweightedGraph6, nodeA, nodeF); + Assert.assertEquals(path.size(), 6); + } + + @Test + public void depthFirstSearchRecursiveUndirectedUnweightedGraph06() throws Exception { + List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedGraph6, nodeA, nodeF); + Assert.assertEquals(path.size(), 6); + } + + @Test + public void djikstraShortestPathUndirectedUnweightedGraph06() throws Exception { + List path = GraphSearch.djikstraShortestPath(UndirectedUnweightedGraph6, nodeA, nodeF); + Assert.assertEquals(path.size(), 2); + } + + @Test + public void breadthFirstSearchUndirectedUnweightedGraph06() throws Exception { + List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedGraph6, nodeA, nodeF); + Assert.assertEquals(path.size(), 2); + Assert.assertTrue(path.get(0).getValue().equals("A")); + Assert.assertTrue(path.get(1).getValue().equals("F")); + } + + @Test + public void depthFirstSearchUndirectedUnweightedGraph07() throws Exception { + List path = GraphSearch.depthFirstSearch(UndirectedUnweightedGraph7, nodeA, nodeF); + Assert.assertEquals(path.size(), 6); + } + + @Test + public void depthFirstSearchRecursiveUndirectedUnweightedGraph07() throws Exception { + List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedGraph7, nodeA, nodeF); + Assert.assertEquals(path.size(), 6); + } + + @Test + public void breadthFirstSearchUndirectedUnweightedGraph07() throws Exception { + List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedGraph7, nodeA, nodeF); + Assert.assertEquals(path.size(), 4); + Assert.assertTrue(path.get(0).getValue().equals("A")); + Assert.assertTrue(path.get(1).getValue().equals("E")); + Assert.assertTrue(path.get(2).getValue().equals("D")); + Assert.assertTrue(path.get(3).getValue().equals("F")); + } + + @Test + public void djikstraShortestPathUndirectedUnweightedGraph07() throws Exception { + List path = GraphSearch.djikstraShortestPath(UndirectedUnweightedGraph7, nodeA, nodeF); + Assert.assertEquals(path.size(), 4); + } + + + +} \ No newline at end of file diff --git a/src/test/java/graphs/UndirectedWeightedGraphTest.java b/src/test/java/graphs/UndirectedWeightedGraphTest.java new file mode 100644 index 0000000..22d4e76 --- /dev/null +++ b/src/test/java/graphs/UndirectedWeightedGraphTest.java @@ -0,0 +1,354 @@ +package graphs; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; + +public class UndirectedWeightedGraphTest { + + private Node nodeA; + private Node nodeB; + private Node nodeC; + private Node nodeD; + private Node nodeE; + private Node nodeF; + private Node nodeG; + private Node nodeH; + private Node nodeZ; + + private Graph UndirectedWeightedGraph11, + UndirectedWeightedGraph12, + UndirectedWeightedGraph13; + + + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Before + public void setUp() throws Exception { + nodeA = new Node("A"); + nodeB = new Node("B"); + nodeC = new Node("C"); + nodeD = new Node("D"); + nodeE = new Node("E"); + nodeF = new Node("F"); + nodeG = new Node("G"); + nodeH = new Node("H"); + nodeZ = new Node("Z"); + + Edge edgeBetweenAandB = new Edge(nodeA, nodeB); + Edge edgeBetweenBandC = new Edge(nodeB, nodeC); + + List nodesForUndirectedUnweightedGraph2 = new LinkedList(Arrays.asList( + nodeA, + nodeB, + nodeC, + nodeD, + nodeE, + nodeF, + nodeG, + nodeH, + nodeZ + )); + Edge edgeBetweenHandZ = new Edge(nodeH, nodeZ); + Edge edgeBetweenEandZ = new Edge(nodeE, nodeZ); + Edge edgeBetweenDandF = new Edge(nodeD, nodeF); + Edge edgeBetweenBandD = new Edge(nodeB, nodeD); + Edge edgeBetweenAandD = new Edge(nodeA, nodeD); + Edge edgeBetweenBandH = new Edge(nodeB, nodeH); + Edge edgeBetweenCandE = new Edge(nodeC, nodeE); + Edge edgeBetweenBandF = new Edge(nodeB, nodeF); + Edge edgeBetweenAandC = new Edge(nodeA, nodeC); + Edge edgeBetweenFandH = new Edge(nodeF, nodeH); + Edge edgeBetweenGandD = new Edge(nodeG,nodeD); + Edge edgeBetweenZandG = new Edge(nodeZ,nodeG); + Edge edgeBetweenZandD = new Edge(nodeZ,nodeD); + Edge edgeBetweenFandB = new Edge(nodeF,nodeB); + Edge edgeBetweenDandC = new Edge(nodeD,nodeC); + Edge edgeBetweenEandD = new Edge(nodeE,nodeD); + Edge edgeBetweenGandA = new Edge(nodeG, nodeA); + Edge edgeBetweenFandA = new Edge(nodeF, nodeA); + Edge edgeBetweenZandC = new Edge(nodeZ, nodeC); + Edge edgeBetweenGandE = new Edge(nodeG, nodeE); + Edge edgeBetweenEandB = new Edge(nodeE, nodeB); + Edge edgeBetweenDandZ = new Edge(nodeD, nodeZ); + + + /* + * graph 8 but weighted + * 12 edges + * a-d + * b-d + * g-d + * z-g + * z-d 2, rest 1 + * h-z + * b-h + * f-b + * c-e + * d-c + * e-d + * d-f + * + * + */ + List edgesForGraph11 = new LinkedList(); + edgesForGraph11.add(edgeBetweenAandD.setWeight(1)); + edgesForGraph11.add(edgeBetweenZandD.setWeight(2)); + edgesForGraph11.add(edgeBetweenBandD.setWeight(1)); + edgesForGraph11.add(edgeBetweenHandZ.setWeight(1)); + edgesForGraph11.add(edgeBetweenBandH.setWeight(1)); + edgesForGraph11.add(edgeBetweenCandE.setWeight(1)); + edgesForGraph11.add(edgeBetweenGandD.setWeight(1)); + edgesForGraph11.add(edgeBetweenZandG.setWeight(1)); + edgesForGraph11.add(edgeBetweenFandB.setWeight(1)); + edgesForGraph11.add(edgeBetweenDandC.setWeight(1)); + edgesForGraph11.add(edgeBetweenEandD.setWeight(1)); + edgesForGraph11.add(edgeBetweenDandF.setWeight(1)); + UndirectedWeightedGraph11 = new Graph(nodesForUndirectedUnweightedGraph2, edgesForGraph11, true); + UndirectedWeightedGraph11.setWeighted(true); + + // + // Graph #11: directed and weighted + // + + /* + * graph 9 but weighted + * 12 edges + * a-b + * b-c + * c-e + * e-d + * g-d + * g-a + * z-g + * h-z + * f-h + * d-f + * e-z + * f-a + * + */ + List edgesForGraph12 = new LinkedList(); + edgesForGraph12.add(edgeBetweenAandB.setWeight(1)); + edgesForGraph12.add(edgeBetweenBandC.setWeight(1)); + edgesForGraph12.add(edgeBetweenCandE.setWeight(1)); + edgesForGraph12.add(edgeBetweenEandZ.setWeight(1)); + edgesForGraph12.add(edgeBetweenEandD.setWeight(2)); + edgesForGraph12.add(edgeBetweenGandD.setWeight(2)); + edgesForGraph12.add(edgeBetweenZandG.setWeight(1)); + edgesForGraph12.add(edgeBetweenHandZ.setWeight(1)); + edgesForGraph12.add(edgeBetweenFandH.setWeight(1)); + edgesForGraph12.add(edgeBetweenDandF.setWeight(1)); + edgesForGraph12.add(edgeBetweenGandA.setWeight(1)); + edgesForGraph12.add(edgeBetweenFandA.setWeight(1)); + UndirectedWeightedGraph12 = new Graph(nodesForUndirectedUnweightedGraph2, edgesForGraph12, true); + UndirectedWeightedGraph12.setWeighted(true); + + // + // Graph #12: directed and weighted + // + + + /* + * graph 10 but weighted + * 10 edges + * a-d + * a-c + * d-c + * z-c + * g-e + * e-b + * b-f + * f-h + * d-z + * g-a + * + */ + + List edgesForGraph13 = new LinkedList(); + edgesForGraph13.add(edgeBetweenAandD.setWeight(1)); + edgesForGraph13.add(edgeBetweenAandC.setWeight(1)); + edgesForGraph13.add(edgeBetweenDandC.setWeight(1)); + edgesForGraph13.add(edgeBetweenBandF.setWeight(1)); + edgesForGraph13.add(edgeBetweenFandH.setWeight(1)); + edgesForGraph13.add(edgeBetweenZandC.setWeight(1)); + edgesForGraph13.add(edgeBetweenGandE.setWeight(2)); + edgesForGraph13.add(edgeBetweenEandB.setWeight(1)); + edgesForGraph13.add(edgeBetweenDandZ.setWeight(1)); + edgesForGraph13.add(edgeBetweenGandA.setWeight(1)); + + + UndirectedWeightedGraph13 = new Graph(nodesForUndirectedUnweightedGraph2, edgesForGraph13, true); + UndirectedWeightedGraph13.setWeighted(true); + + // + // Graph #13: directed and weighted + // + + + } + + @Test + public void depthFirstSearchDirectedWeightedGraph11() throws Exception { + List path = GraphSearch.depthFirstSearch(UndirectedWeightedGraph11, nodeH, nodeB); + Assert.assertEquals(path.size(), 6); + Assert.assertTrue(path.get(0).getValue().equals("H")); + Assert.assertTrue(path.get(1).getValue().equals("Z")); + Assert.assertTrue(path.get(2).getValue().equals("G")); + Assert.assertTrue(path.get(3).getValue().equals("D")); + Assert.assertTrue(path.get(4).getValue().equals("F")); + Assert.assertTrue(path.get(5).getValue().equals("B")); + } + + @Test + public void depthFirstSearchRecursiveDirectedWeightedGraph11() throws Exception { + List path = GraphSearch.depthFirstSearchRecursive(UndirectedWeightedGraph11, nodeH, nodeB); + Assert.assertEquals(path.size(), 6); + Assert.assertTrue(path.get(0).getValue().equals("H")); + Assert.assertTrue(path.get(1).getValue().equals("Z")); + Assert.assertTrue(path.get(2).getValue().equals("G")); + Assert.assertTrue(path.get(3).getValue().equals("D")); + Assert.assertTrue(path.get(4).getValue().equals("F")); + Assert.assertTrue(path.get(5).getValue().equals("B")); + } + + @Test + public void breadthFirstSearchDirectedWeightedGraph11() throws Exception { + List path = GraphSearch.breadthFirstSearch(UndirectedWeightedGraph11, nodeH, nodeB); + Assert.assertEquals(path.size(), 5); + Assert.assertTrue(path.get(0).getValue().equals("H")); + Assert.assertTrue(path.get(1).getValue().equals("Z")); + Assert.assertTrue(path.get(2).getValue().equals("D")); + Assert.assertTrue(path.get(3).getValue().equals("F")); + Assert.assertTrue(path.get(4).getValue().equals("B")); + } + + @Test + public void djikstraShortestPathUndirectedUnweightedGraph11() throws Exception { + List path = GraphSearch.djikstraShortestPath(UndirectedWeightedGraph11, nodeH, nodeB); + Assert.assertEquals(path.size(), 5); + Assert.assertTrue(path.get(0).getValue().equals("H")); + Assert.assertTrue(path.get(1).getValue().equals("Z")); + Assert.assertTrue(path.get(2).getValue().equals("D")); + Assert.assertTrue(path.get(3).getValue().equals("F")); + Assert.assertTrue(path.get(4).getValue().equals("B")); + } + + @Test + public void depthFirstSearchDirectedWeightedGraph12() throws Exception { + List path = GraphSearch.depthFirstSearch(UndirectedWeightedGraph12, nodeE, nodeF); + Assert.assertEquals(path.size(), 5); + Assert.assertTrue(path.get(0).getValue().equals("E")); + Assert.assertTrue(path.get(1).getValue().equals("Z")); + Assert.assertTrue(path.get(2).getValue().equals("G")); + Assert.assertTrue(path.get(3).getValue().equals("D")); + Assert.assertTrue(path.get(4).getValue().equals("F")); + } + + @Test + public void depthFirstSearchRecursiveDirectedWeightedGraph12() throws Exception { + List path = GraphSearch.depthFirstSearchRecursive(UndirectedWeightedGraph12, nodeE, nodeF); + Assert.assertEquals(path.size(), 5); + Assert.assertTrue(path.get(0).getValue().equals("E")); + Assert.assertTrue(path.get(1).getValue().equals("Z")); + Assert.assertTrue(path.get(2).getValue().equals("G")); + Assert.assertTrue(path.get(3).getValue().equals("D")); + Assert.assertTrue(path.get(4).getValue().equals("F")); + } + + @Test + public void breadthFirstSearchDirectedWeightedGraph12() throws Exception { + List path = GraphSearch.breadthFirstSearch(UndirectedWeightedGraph12, nodeE, nodeF); + Assert.assertEquals(path.size(), 3); + Assert.assertTrue(path.get(0).getValue().equals("E")); + Assert.assertTrue(path.get(1).getValue().equals("D")); + Assert.assertTrue(path.get(2).getValue().equals("F")); + } + + @Test + public void djikstraShortestPathUndirectedUnweightedGraph12() throws Exception { + List path = GraphSearch.djikstraShortestPath(UndirectedWeightedGraph12, nodeE, nodeF); + Assert.assertEquals(path.size(), 3); + Assert.assertTrue(path.get(0).getValue().equals("E")); + Assert.assertTrue(path.get(1).getValue().equals("D")); + Assert.assertTrue(path.get(2).getValue().equals("F")); + } + + @Test + public void depthFirstSearchDirectedWeightedGraph13() throws Exception { + List path = GraphSearch.depthFirstSearch(UndirectedWeightedGraph13, nodeG, nodeH); + Assert.assertEquals(path.size(), 5); + Assert.assertTrue(path.get(0).getValue().equals("G")); + Assert.assertTrue(path.get(1).getValue().equals("E")); + Assert.assertTrue(path.get(2).getValue().equals("B")); + Assert.assertTrue(path.get(3).getValue().equals("F")); + Assert.assertTrue(path.get(4).getValue().equals("H")); + } + + @Test + public void depthFirstSearchRecursiveDirectedWeightedGraph13() throws Exception { + List path = GraphSearch.depthFirstSearchRecursive(UndirectedWeightedGraph13, nodeG, nodeH); + Assert.assertEquals(path.size(), 5); + Assert.assertTrue(path.get(0).getValue().equals("G")); + Assert.assertTrue(path.get(1).getValue().equals("E")); + Assert.assertTrue(path.get(2).getValue().equals("B")); + Assert.assertTrue(path.get(3).getValue().equals("F")); + Assert.assertTrue(path.get(4).getValue().equals("H")); + } + + @Test + public void djikstraShortestPathUndirectedUnweightedGraph13() throws Exception { + List path = GraphSearch.djikstraShortestPath(UndirectedWeightedGraph13, nodeG, nodeH); + Assert.assertEquals(path.size(), 5); + Assert.assertTrue(path.get(0).getValue().equals("G")); + Assert.assertTrue(path.get(1).getValue().equals("E")); + Assert.assertTrue(path.get(2).getValue().equals("B")); + Assert.assertTrue(path.get(3).getValue().equals("F")); + Assert.assertTrue(path.get(4).getValue().equals("H")); + } + + @Test + public void breadthFirstSearchDirectedWeightedGraph13() throws Exception { + List path = GraphSearch.breadthFirstSearch(UndirectedWeightedGraph13, nodeG, nodeH); + Assert.assertEquals(path.size(), 5); + Assert.assertTrue(path.get(0).getValue().equals("G")); + Assert.assertTrue(path.get(1).getValue().equals("E")); + Assert.assertTrue(path.get(2).getValue().equals("B")); + Assert.assertTrue(path.get(3).getValue().equals("F")); + Assert.assertTrue(path.get(4).getValue().equals("H")); + } + + // same as graph 13, except start at e and look for c, un connected, will need to restart + @Test + public void depthFirstSearchDirectedWeightedGraph14() throws Exception { + List path = GraphSearch.depthFirstSearch(UndirectedWeightedGraph13, nodeE, nodeC); + Assert.assertEquals(path.size(), 0); + } + + @Test + public void depthFirstSearchRecursiveDirectedWeightedGraph14() throws Exception { + List path = GraphSearch.depthFirstSearchRecursive(UndirectedWeightedGraph13, nodeE, nodeC); + Assert.assertEquals(path.size(), 0); + } + + @Test + public void breadthFirstSearchDirectedWeightedGraph14() throws Exception { + List path = GraphSearch.breadthFirstSearch(UndirectedWeightedGraph13, nodeE, nodeC); + Assert.assertEquals(path.size(), 0); + } + + @Test + public void djikstraShortestPathUndirectedUnweightedGraph14() throws Exception { + List path = GraphSearch.djikstraShortestPath(UndirectedWeightedGraph13, nodeE, nodeC); + Assert.assertEquals(path.size(), 0); + } + +} \ No newline at end of file diff --git a/src/test/java/graphs/graph5.png b/src/test/java/graphs/graph5.png new file mode 100644 index 0000000000000000000000000000000000000000..e77b4f97d0ba470a3a86a5acaf14526e3ae70c5b GIT binary patch literal 11687 zcmb7q2|Sc-+x~3{iO{C(txC4+WGiLKR>;1qj9nVp%}Avpo)WS}2}$;y#*(CxE!meD zNtUt3*q8r#>v_L-dEV#$`@UZ_&D=9{&$XP_aUREUp7$^6s4+8gFd_)Ttf78R4?(E$ z2txG-107sZoNGM_|IyiMs+~hN(Lc$A^hmg}-Cf<}27>I^jsBxT;u7}5MS84;_IY~J zc1E_{bV8STI^hzxgMl$t#m&X#sw);=B8ZB|RU7QpD|}uKSPY+Ym*B2=vKK&uQ7|Er6d?VnEMet7rpmL+c8ld$wX z^z#)lxxlqjkFtcOX9_1Z$_MXqe(UYc)Q*=r!L^gzbb9(*R>{EYsFOw>zhKxI@~2qo;l6Up@03Ke0}tS9+BhCS+DT`aFc^tA$tp`Ta01TIKYWVG&$LdQzY%ZowXR z&9Q8CVX`fp`!u%Sv-A367(Z3Zc7dn|&wPF!2v}~gavi_EFip%62^iD-Xw0gJ8MwPCRh z1frfak3@aCA|WYxv{qE&^y!lt<6~o&ME4t5StY$2%%u*(mseB_&w9)Fz$RE{`b^~2 z&r@=6{T*`hE2AmC@NzWl*zL;L*aHv4!yTQS-(-u~<~>zaRV{SwmwU$t+tM)TuC^lzIHOvHAj*k-p^SIVejb^N<`Q9LI3C{!Pp|)? zLRYk5*rTWPdP)j;smCd27CR%h|L*gP$FDTx6?DJ3Rl}EvAh~<|s62spw#bcZ*Hnv4C)bk3#vD4o^*2uVlTxC_8DPtc z-=;tF{rv6M%E}6soK+(1>(*cHxiX)wG`Un>(f#AcOLRtulA4`7JRa|)K_r;yYuE0U(}*6O*Vff_x^m?l zH#hgM)pgj?9+=WjE}3M1#hm43pT_3qlS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JU2XkyB?&z{8#P|$?!PNYQ#a}5du|8U*8bm?jEweBo@B-=kx1O0`+pavqt zpkIyO@gJyBeGpEzIdqc&Y9Qla?2yD@TR_3BO&MkxLi^h2xvhMMZ}{@%%SA7AKp1|I z=HIxH7FGZY_EUB%CC{vU#M513>FAJEi1t$T41*WIf1qHe^Timo(#;o|KRo0VSzfho zO1N(R+vIV%A{Lt#wGQ1t2F(hKeMhIE&8l6}1>M@9XmLr&_QL$lv7`+RlnAgB7F$$U z#ztFHvK@XqNL(nkOaYChK#|_2)sMK`D@p@c61*t$k;Q={0YzHLt{1Epv7jQf;|fatsWS5F;w zzS`sIDQ0K(G#pj+0TAnb3t5dr;Lm$l5cD(l46+~zzf9gi1VMTKf0|OFJISeYNHrB2 zWgq_y1d*NSXKnul1aqAqp4kd8pKF3l{my`aNK-8=xb44TAbNEFih<~%_%9fU$m{_N zTIk5X70^+fJ$c}N+8R;coJ0+veL6*>$WtTu9HMbv=Unz#>s$X1 DY@}qg literal 0 HcmV?d00001 diff --git a/src/test/java/graphs/graph6.png b/src/test/java/graphs/graph6.png new file mode 100644 index 0000000000000000000000000000000000000000..49fe6ae4e2045ae540204444d51ae7a81518a7c5 GIT binary patch literal 24255 zcmaI;by$^M_XP?g(j_6%(jko?Dka?#N-2$WcQ>1E0TGcBkyelpkZ$QxN?J+j6j8o; zKkx55*LD6mPbk86?{%-3bIdWuT+te83WRvncxY&7gi4CCkI>N2gVE5gB;jDecO(u+ zS>ZP0Wa@21OlwvB2ANagg)%1{PX zLe5;|WREa9Wi=%+u1IO2sLaV%FaFh~*Cz<}-nOzFItXYnS}PC}bQ`J)%o+A+9yV*` zC%78QfCK+Y3n_BoBVU9vD58;KND;$-ENHm@`ypxY|Gt5NEBU`~gkmuK_X-Rt^rZj( zdgutdd@3fqY9_>#QcGJqud?b|oy^!Ru} zdwY8mcmYn;r%#b#VOM>R)~{e=W8b@XuXSP~l@m*9kMgPrE{b7BU0a*Hq_i~ceP5rl znD-vq@$oTyA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Y^B{j+1aPMY7)%!9$&Axu4%u zki6nbg=I>$!X!+Qy{)F#7tQXm1N~F)h|&QhEoo~U)BHd6N@H0XaD8FsmshHC&VthmLmid2XXQ#k| z;a&HDQOK}63sjb+c`+*4PVXEXMv-V?Jagq|p^QL5t*M(lFU?n4%=y zDP%Zf!_hY^h$uXBCh&=7;--1-g3A;_fd~uHi?fcc>X!DK3^t~x?s(2ZU}Bj#fBd>X187f zpX&K#(}g++G_p0kuJ+`K7ydp?^~)K;w~3UK)TXw!dg&kkmzy=TPcKd!8VcI8 zIJ*jD_@Ev!fe4dVijA&n4jFkq|2-H!p++GH$HgKFHpH?LMBl3BNzAxAzIId!C@IKB+WddW6KmDw!&u>HEZ~R>xWx>?kqn_mA*T!rs}5h}^qQqqpYb(3 z!a(SK+uq}AxQxmC^6bc35k1Q0?qSZs?3TSpYQYTvtLn;6DxO_Fa&ivJ=!|;LPFr8xF~#)Ild+wat9Vq9O)m``Ar_} zUsQ2WoQ!SY@oofFlvWW>%ajCAEV_Fj(bA;*KH&?&#E5lwyQ_^6O~ rPiP%NScZKOfBW&jk@5d|t~g9L(zu{AC1dAZ0zVrqwwT{HWrzO@tH<&N literal 0 HcmV?d00001 diff --git a/src/test/java/graphs/graph7.png b/src/test/java/graphs/graph7.png new file mode 100644 index 0000000000000000000000000000000000000000..388d8701d6985e07e5c4f50b1ac80c9b8e3fd9a2 GIT binary patch literal 14623 zcmbWec|6on*f#zhCdNKd*}`a{5VAzpv80laJCux1I-@HOQ zK}SQ)1F+QCyiP6j4EY94NGcJ4mlAq1&;*;)J8-9h;~`8cAkUcae(N7RlMf>6+P zbrpkvAB&@IkIef+TmKv`FbZ6q+88ng_C9&p-uZG=GdI`qc@jrLN!Hhvu@X&r;TmTR?>ONjjuL%;o)vx) z{pe_~XX4teW|`$zONvR2+4JnG9FMgw(_e>8qCFB2}9m3?k#z>VB(5_v&x5+3Ts~^S1Y?iyS~pX zjaD1`EsdNXunbd_=cJ6=P`6-UX2>BO-;Lc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2a0 zY5)yV_XQn)%i`E|dCWYD3^a38D7asyiAX!334}A_%L8EB*g(NlT%XGuMBbiIs(mtEa#X-QAgtxZ~X10PK#Fp99|r zD7Ux~n&?0nSlPZRntMH?>I5~I;)F0oAbMeM`Cw^z`Y%a8uDJU7wAb|Kqi4%f zCuo5mG!R5OyzW#|y2X%r{dCjSY7gvMvV^qsl{spN8pvxhp8kidfY?Ev7F0fexUO?p z0`%RFc@iiGCsxOTmjM$1hTM<^Z37xZ7XxGfm6Y>5>*PxBM+u1;US4Zz1|<8EU$x4{_%;bC1- z!r7C|-r|(?$T$uZbU{HuRTz!o<5$?ne_Q1DIu2GTKnaGy*}{dW(g&9D~A)hg3K&%7EHJ~Vpf4;A;w*(dSSGz|Vuk$-E zA}Ch;RBUVGm~-)uB=iHpYH~A`=j`HZz~9W3(%DuXMk$z)YFv`#$1DkD-_p(+(D@Zwz43pYj%xs zj|xWvX2Zz#mlD4r#pUak`oG|4%A(Z(TfZkcg4mt` literal 0 HcmV?d00001 From ada9e370f47abdf771c767e44bf1cc9cabcd95a0 Mon Sep 17 00:00:00 2001 From: sam Date: Sun, 30 Oct 2016 19:54:23 -0500 Subject: [PATCH 08/10] updates gitignore --- .gitignore | 2 +- .idea/compiler.xml | 22 ------------------- .idea/copyright/profiles_settings.xml | 3 --- .idea/misc.xml | 19 ---------------- .idea/modules.xml | 8 ------- .idea/modules/1748581304/coding-exercises.iml | 20 ----------------- src/main/java/graphs/GraphSearch.java | 1 - 7 files changed, 1 insertion(+), 74 deletions(-) delete mode 100644 .idea/compiler.xml delete mode 100644 .idea/copyright/profiles_settings.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/modules/1748581304/coding-exercises.iml diff --git a/.gitignore b/.gitignore index 9de69da..120106a 100644 --- a/.gitignore +++ b/.gitignore @@ -53,4 +53,4 @@ gradle-app.setting # gimp image file to make pngs of graphs for tests *.xcf -.idea/ +.idea diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index 96cc43e..0000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml deleted file mode 100644 index e7bedf3..0000000 --- a/.idea/copyright/profiles_settings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 10be079..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 1fc19bc..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/modules/1748581304/coding-exercises.iml b/.idea/modules/1748581304/coding-exercises.iml deleted file mode 100644 index e63c3ee..0000000 --- a/.idea/modules/1748581304/coding-exercises.iml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/java/graphs/GraphSearch.java b/src/main/java/graphs/GraphSearch.java index f9f597a..a5a01dd 100644 --- a/src/main/java/graphs/GraphSearch.java +++ b/src/main/java/graphs/GraphSearch.java @@ -226,7 +226,6 @@ public static List djikstraShortestPath(Graph graph, Node start, Node fini double newDistance = currentDistance + edge.getWeight(); if(newDistance < distanceMap.get(nextNode)) { distanceMap.put(nextNode, newDistance); - // previousNodeMap will be a map of all nodes to their previous node previousNodeMap.put(nextNode, currentNode); } } From c83f993bce02a8a65a7b4de595b01fc6650fa17e Mon Sep 17 00:00:00 2001 From: sam Date: Thu, 3 Nov 2016 21:30:30 -0500 Subject: [PATCH 09/10] updates graph search --- src/main/java/graphs/GraphSearch.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/graphs/GraphSearch.java b/src/main/java/graphs/GraphSearch.java index a5a01dd..12c017a 100644 --- a/src/main/java/graphs/GraphSearch.java +++ b/src/main/java/graphs/GraphSearch.java @@ -200,7 +200,7 @@ public static List djikstraShortestPath(Graph graph, Node start, Node fini throw new IllegalArgumentException("null start node or target node"); } if(! (graph.getNodes().contains(start) && graph.getNodes().contains(finish))) { - return new LinkedList(); + throw new IllegalArgumentException("either start node or target node are not contained in graph"); } LinkedList nodes = new LinkedList<>(graph.getNodes()); From dbb6d5fab81a3616d2241b614bf2973123e66734 Mon Sep 17 00:00:00 2001 From: sam Date: Thu, 3 Nov 2016 21:31:13 -0500 Subject: [PATCH 10/10] removes old single test class --- src/test/java/graphs/GraphSearchTest.java | 1117 --------------------- 1 file changed, 1117 deletions(-) delete mode 100644 src/test/java/graphs/GraphSearchTest.java diff --git a/src/test/java/graphs/GraphSearchTest.java b/src/test/java/graphs/GraphSearchTest.java deleted file mode 100644 index add916d..0000000 --- a/src/test/java/graphs/GraphSearchTest.java +++ /dev/null @@ -1,1117 +0,0 @@ -package graphs; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; - -/** - * Created by shalka on 8/14/16. - */ -public class GraphSearchTest { - - private Node nodeA; - private Node nodeB; - private Node nodeC; - private Node nodeD; - private Node nodeE; - private Node nodeF; - private Node nodeG; - private Node nodeH; - private Node nodeZ; - - private Graph UndirectedUnweightedgraph1, - UndirectedUnweightedgraph2, - UndirectedUnweightedgraph3, - UndirectedUnweightedgraph4, - UndirectedUnweightedgraph5, - UndirectedUnweightedgraph6, - UndirectedUnweightedgraph7, - DirectedUnweightedGraph8, - DirectedUnweightedGraph9, - DirectedUnweightedGraph10, - DirectedWeightedGraph11, - DirectedWeightedGraph12, - DirectedWeightedGraph13; - - - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Before - public void setUp() throws Exception { - nodeA = new Node("A"); - nodeB = new Node("B"); - nodeC = new Node("C"); - nodeD = new Node("D"); - nodeE = new Node("E"); - nodeF = new Node("F"); - nodeG = new Node("G"); - nodeH = new Node("H"); - nodeZ = new Node("Z"); - - List nodesForUndirectedUnweightedGraph1 = new LinkedList(Arrays.asList( - nodeA, - nodeB, - nodeC, - nodeD, - nodeE, - nodeF - )); - - Edge edgeBetweenAandB = new Edge(nodeA, nodeB); - Edge edgeBetweenBandC = new Edge(nodeB, nodeC); - Edge edgeBetweenCandD = new Edge(nodeC, nodeD); - Edge edgeBetweenDandE = new Edge(nodeD, nodeE); - Edge edgeBetweenEandF = new Edge(nodeE, nodeF); - - List edgesForUndirectedUnweightedGraph1 = new LinkedList(); - edgesForUndirectedUnweightedGraph1.add(edgeBetweenAandB); - edgesForUndirectedUnweightedGraph1.add(edgeBetweenBandC); - edgesForUndirectedUnweightedGraph1.add(edgeBetweenCandD); - edgesForUndirectedUnweightedGraph1.add(edgeBetweenDandE); - edgesForUndirectedUnweightedGraph1.add(edgeBetweenEandF); - // - // Graph #1: Straight line (unweighted, undirected) - // A -> B -> C -> D -> E -> F - // - UndirectedUnweightedgraph1 = new Graph(nodesForUndirectedUnweightedGraph1, edgesForUndirectedUnweightedGraph1); - - - List nodesForUndirectedUnweightedGraph2 = new LinkedList(Arrays.asList( - nodeA, - nodeB, - nodeC, - nodeD, - nodeE, - nodeF, - nodeG, - nodeH, - nodeZ - )); - - Edge edgeBetweenFandG = new Edge(nodeF, nodeG); - Edge edgeBetweenGandH = new Edge(nodeG, nodeH); - Edge edgeBetweenAandZ = new Edge(nodeA, nodeZ); - Edge edgeBetweenHandZ = new Edge(nodeH, nodeZ); - - List edgesForUndirectedUnweightedGraph2 = new LinkedList(); - edgesForUndirectedUnweightedGraph2.add(edgeBetweenAandB); - edgesForUndirectedUnweightedGraph2.add(edgeBetweenBandC); - edgesForUndirectedUnweightedGraph2.add(edgeBetweenCandD); - edgesForUndirectedUnweightedGraph2.add(edgeBetweenDandE); - edgesForUndirectedUnweightedGraph2.add(edgeBetweenEandF); - edgesForUndirectedUnweightedGraph2.add(edgeBetweenFandG); - edgesForUndirectedUnweightedGraph2.add(edgeBetweenGandH); - edgesForUndirectedUnweightedGraph2.add(edgeBetweenAandZ); - edgesForUndirectedUnweightedGraph2.add(edgeBetweenHandZ); - - // - // Graph #2: Different solutions for DFS and BFS (unweighted, undirected) - // A -> B -> C -> D -> E -> F -> G -> H - // \ / - // \------------> Z -------------/ - // - UndirectedUnweightedgraph2 = new Graph(nodesForUndirectedUnweightedGraph2, edgesForUndirectedUnweightedGraph2); - - - - // graph 2 has all nodes A - H & Z - List nodesForUndirectedUnweightedGraph3 = nodesForUndirectedUnweightedGraph2; - -// Edge edgeBetweenHandZ = new Edge(nodeZ, nodeH); - /* - * make edges, then make edge list: - * graph 3 has edges: - * A - D - * B - D - * B - C ~ - * C - D ~ - * D - F - * D - H - * H - Z ~ - * E - Z - * E - G - */ - - Edge edgeBetweenEandZ = new Edge(nodeE, nodeZ); - Edge edgeBetweenEandG = new Edge(nodeE, nodeG); - Edge edgeBetweenDandH = new Edge(nodeD, nodeH); - Edge edgeBetweenDandF = new Edge(nodeD, nodeF); - Edge edgeBetweenBandD = new Edge(nodeB, nodeD); - Edge edgeBetweenAandD = new Edge(nodeA, nodeD); - - List edgesForUndirectedUnweightedGraph3 = new LinkedList(); - edgesForUndirectedUnweightedGraph3.add(edgeBetweenBandC); - edgesForUndirectedUnweightedGraph3.add(edgeBetweenCandD); - edgesForUndirectedUnweightedGraph3.add(edgeBetweenHandZ); - edgesForUndirectedUnweightedGraph3.add(edgeBetweenEandZ); - edgesForUndirectedUnweightedGraph3.add(edgeBetweenEandG); - edgesForUndirectedUnweightedGraph3.add(edgeBetweenDandH); - edgesForUndirectedUnweightedGraph3.add(edgeBetweenDandF); - edgesForUndirectedUnweightedGraph3.add(edgeBetweenBandD); - edgesForUndirectedUnweightedGraph3.add(edgeBetweenAandD); - - // - // Graph #3: see UndirectedUnweightedgraph3.png - // - UndirectedUnweightedgraph3 = new Graph(nodesForUndirectedUnweightedGraph3, edgesForUndirectedUnweightedGraph3); - - - - // graph 2 has all nodes A - H & Z - List nodesForUndirectedUnweightedGraph4 = nodesForUndirectedUnweightedGraph2; - -// Edge edgeBetweenHandZ = new Edge(nodeZ, nodeH); - /* - * make edges, then make edge list: - * graph 4 has edges: - * a-b ~ - * b-e - * b-h - * e-g ~ - * g-h ~ - * h-z ~ - * h-d ~ - * d-f ~ - * d-c ~ - * c-f - * - */ - Edge edgeBetweenBandE = new Edge(nodeB, nodeE); - Edge edgeBetweenBandH = new Edge(nodeB, nodeH); - Edge edgeBetweenCandF = new Edge(nodeC, nodeF); - - - List edgesForUndirectedUnweightedGraph4 = new LinkedList(); - edgesForUndirectedUnweightedGraph4.add(edgeBetweenCandD); - edgesForUndirectedUnweightedGraph4.add(edgeBetweenHandZ); - edgesForUndirectedUnweightedGraph4.add(edgeBetweenEandG); - edgesForUndirectedUnweightedGraph4.add(edgeBetweenDandH); - edgesForUndirectedUnweightedGraph4.add(edgeBetweenDandF); - edgesForUndirectedUnweightedGraph4.add(edgeBetweenAandB); - edgesForUndirectedUnweightedGraph4.add(edgeBetweenGandH); - edgesForUndirectedUnweightedGraph4.add(edgeBetweenBandE); - edgesForUndirectedUnweightedGraph4.add(edgeBetweenBandH); - edgesForUndirectedUnweightedGraph4.add(edgeBetweenCandF); - - - // - // Graph #4: see UndirectedUnweightedgraph4.png - // - UndirectedUnweightedgraph4 = new Graph(nodesForUndirectedUnweightedGraph4, edgesForUndirectedUnweightedGraph4); - - - // graph 2 has all nodes A - H & Z - List nodesForUndirectedUnweightedGraph5 = nodesForUndirectedUnweightedGraph2; - // - // Graph #5: graph with nodes from graph 2 and edges from graph 1 - // - // start and target have no path, will return empty list - UndirectedUnweightedgraph5 = new Graph(nodesForUndirectedUnweightedGraph5, edgesForUndirectedUnweightedGraph1); - - - - // graph 2 has all nodes A - H & Z - List nodesForUndirectedUnweightedGraph6 = nodesForUndirectedUnweightedGraph2; - /* - * make edges, then make edge list: - * graph 6 nodes A-F, and all edges (15) - * a-b ~ - * a-c - * a-d ~ - * a-e - * a-f - * b-c ~ - * b-d ~ - * b-e ~ - * b-f - * c-d ~ - * c-e - * c-f ~ - * d-e ~ - * d-f ~ - * e-f ~ - * - */ - - Edge edgeBetweenCandE = new Edge(nodeC, nodeE); - Edge edgeBetweenBandF = new Edge(nodeB, nodeF); - Edge edgeBetweenAandF = new Edge(nodeA, nodeF); - Edge edgeBetweenAandE = new Edge(nodeA, nodeE); - Edge edgeBetweenAandC = new Edge(nodeA, nodeC); - - - List edgesForUndirectedUnweightedGraph6 = new LinkedList(edgesForUndirectedUnweightedGraph1); - edgesForUndirectedUnweightedGraph6.add(edgeBetweenCandF); - edgesForUndirectedUnweightedGraph6.add(edgeBetweenAandB); - edgesForUndirectedUnweightedGraph6.add(edgeBetweenAandD); - edgesForUndirectedUnweightedGraph6.add(edgeBetweenBandC); - edgesForUndirectedUnweightedGraph6.add(edgeBetweenBandD); - edgesForUndirectedUnweightedGraph6.add(edgeBetweenBandE); - edgesForUndirectedUnweightedGraph6.add(edgeBetweenCandD); - edgesForUndirectedUnweightedGraph6.add(edgeBetweenCandE); - edgesForUndirectedUnweightedGraph6.add(edgeBetweenDandE); - edgesForUndirectedUnweightedGraph6.add(edgeBetweenDandF); - edgesForUndirectedUnweightedGraph6.add(edgeBetweenEandF); - edgesForUndirectedUnweightedGraph6.add(edgeBetweenBandF); - edgesForUndirectedUnweightedGraph6.add(edgeBetweenAandF); - edgesForUndirectedUnweightedGraph6.add(edgeBetweenAandE); - edgesForUndirectedUnweightedGraph6.add(edgeBetweenAandC); - - // - // Graph #6: graph with nodes from graph 1, fully connected - // - UndirectedUnweightedgraph6 = new Graph(nodesForUndirectedUnweightedGraph6, edgesForUndirectedUnweightedGraph6); - - - - // graph 2 has all nodes A - H & Z - List nodesForUndirectedUnweightedGraph7 = nodesForUndirectedUnweightedGraph2; - // edges needed (17): - /* - * a-b ~ - * a-e ~ - * a-z ~ - * a-g - * b-g - * b-e ~ - * e-g ~ - * g-z - * e-z ~ - * d-e ~ - * h-z ~ - * d-h ~ - * c-d ~ - * d-f ~ - * c-h - * c-f ~ - * f-h - * - */ - - - Edge edgeBetweenCandH = new Edge(nodeC, nodeH); - Edge edgeBetweenBandG = new Edge(nodeB, nodeG); - Edge edgeBetweenAandG = new Edge(nodeA, nodeG); - Edge edgeBetweenGandZ = new Edge(nodeG, nodeZ); - Edge edgeBetweenFandH = new Edge(nodeF, nodeH); - - List edgesForUndirectedUnweightedGraph7 = new LinkedList(); - edgesForUndirectedUnweightedGraph7.add(edgeBetweenAandB); - edgesForUndirectedUnweightedGraph7.add(edgeBetweenAandE); - edgesForUndirectedUnweightedGraph7.add(edgeBetweenAandZ); - edgesForUndirectedUnweightedGraph7.add(edgeBetweenBandE); - edgesForUndirectedUnweightedGraph7.add(edgeBetweenCandD); - edgesForUndirectedUnweightedGraph7.add(edgeBetweenCandF); - edgesForUndirectedUnweightedGraph7.add(edgeBetweenDandE); - edgesForUndirectedUnweightedGraph7.add(edgeBetweenDandF); - edgesForUndirectedUnweightedGraph7.add(edgeBetweenDandH); - edgesForUndirectedUnweightedGraph7.add(edgeBetweenEandG); - edgesForUndirectedUnweightedGraph7.add(edgeBetweenEandZ); - edgesForUndirectedUnweightedGraph7.add(edgeBetweenHandZ); - edgesForUndirectedUnweightedGraph7.add(edgeBetweenCandH); - edgesForUndirectedUnweightedGraph7.add(edgeBetweenBandG); - edgesForUndirectedUnweightedGraph7.add(edgeBetweenAandG); - edgesForUndirectedUnweightedGraph7.add(edgeBetweenGandZ); - edgesForUndirectedUnweightedGraph7.add(edgeBetweenFandH); - // - // Graph #7: graph7.png - // - UndirectedUnweightedgraph7 = new Graph(nodesForUndirectedUnweightedGraph7, edgesForUndirectedUnweightedGraph7); - - - - /* - * graph 8 - * 12 edges - * a-d ~ - * b-d ~ - * g-d - * z-g - * z-d - * h-z ~ - * b-h ~ - * f-b - * c-e ~ - * d-c - * e-d - * d-f - */ - - - Edge edgeBetweenGandD = new Edge(nodeG,nodeD); - Edge edgeBetweenZandG = new Edge(nodeZ,nodeG); - Edge edgeBetweenZandD = new Edge(nodeZ,nodeD); - Edge edgeBetweenFandB = new Edge(nodeF,nodeB); - Edge edgeBetweenDandC = new Edge(nodeD,nodeC); - Edge edgeBetweenEandD = new Edge(nodeE,nodeD); - - List edgesForGraph8 = new LinkedList(); - edgesForGraph8.add(edgeBetweenAandD); - edgesForGraph8.add(edgeBetweenBandD); - edgesForGraph8.add(edgeBetweenHandZ); - edgesForGraph8.add(edgeBetweenBandH); - edgesForGraph8.add(edgeBetweenCandE); - edgesForGraph8.add(edgeBetweenGandD); - edgesForGraph8.add(edgeBetweenZandG); - edgesForGraph8.add(edgeBetweenZandD); - edgesForGraph8.add(edgeBetweenFandB); - edgesForGraph8.add(edgeBetweenDandC); - edgesForGraph8.add(edgeBetweenEandD); - edgesForGraph8.add(edgeBetweenDandF); - - - // use nodes from graph 2 - DirectedUnweightedGraph8 = new Graph(nodesForUndirectedUnweightedGraph2, edgesForGraph8, true); - // - // Graph #8: directed and unweighted - // - - - /* - * graph 9 - * 12 edges - * a-b - * b-c - * c-e - * e-d - * g-d - * g-a - * z-g - * h-z - * f-h - * d-f - * e-z - * f-a - * - */ - - Edge edgeBetweenGandA = new Edge(nodeG, nodeA); - Edge edgeBetweenFandA = new Edge(nodeF, nodeA); - - List edgesForGraph9 = new LinkedList(); - edgesForGraph9.add(edgeBetweenAandB); - edgesForGraph9.add(edgeBetweenBandC); - edgesForGraph9.add(edgeBetweenCandE); - edgesForGraph9.add(edgeBetweenEandZ); - edgesForGraph9.add(edgeBetweenEandD); - edgesForGraph9.add(edgeBetweenGandD); - edgesForGraph9.add(edgeBetweenZandG); - edgesForGraph9.add(edgeBetweenHandZ); - edgesForGraph9.add(edgeBetweenFandH); - edgesForGraph9.add(edgeBetweenDandF); - edgesForGraph9.add(edgeBetweenGandA); - edgesForGraph9.add(edgeBetweenFandA); - - - DirectedUnweightedGraph9 = new Graph(nodesForUndirectedUnweightedGraph2, edgesForGraph9, true); - // - // Graph #9: directed and unweighted - // - - - /* - * graph 10 - * 10 edges - * a-d - * a-c - * d-c - * z-c - * g-e - * e-b - * b-f - * f-h - * d-z - * g-a - */ - - Edge edgeBetweenZandC = new Edge(nodeZ, nodeC); - Edge edgeBetweenGandE = new Edge(nodeG, nodeE); - Edge edgeBetweenEandB = new Edge(nodeE, nodeB); - Edge edgeBetweenDandZ = new Edge(nodeD, nodeZ); - List edgesForGraph10 = new LinkedList(); - edgesForGraph10.add(edgeBetweenAandD); - edgesForGraph10.add(edgeBetweenAandC); - edgesForGraph10.add(edgeBetweenDandC); - edgesForGraph10.add(edgeBetweenBandF); - edgesForGraph10.add(edgeBetweenFandH); - edgesForGraph10.add(edgeBetweenZandC); - edgesForGraph10.add(edgeBetweenGandE); - edgesForGraph10.add(edgeBetweenEandB); - edgesForGraph10.add(edgeBetweenDandZ); - edgesForGraph10.add(edgeBetweenGandA); - - DirectedUnweightedGraph10 = new Graph(nodesForUndirectedUnweightedGraph2, edgesForGraph10, true); - // - // Graph #10: directed and unweighted - // - - - /* - * graph 8 but weighted - * 12 edges - * a-d - * b-d - * g-d - * z-g - * z-d 2, rest 1 - * h-z - * b-h - * f-b - * c-e - * d-c - * e-d - * d-f - * - * - */ - List edgesForGraph11 = new LinkedList(); - edgesForGraph11.add(edgeBetweenAandD.setWeight(1)); - edgesForGraph11.add(edgeBetweenZandD.setWeight(2)); - edgesForGraph11.add(edgeBetweenBandD.setWeight(1)); - edgesForGraph11.add(edgeBetweenHandZ.setWeight(1)); - edgesForGraph11.add(edgeBetweenBandH.setWeight(1)); - edgesForGraph11.add(edgeBetweenCandE.setWeight(1)); - edgesForGraph11.add(edgeBetweenGandD.setWeight(1)); - edgesForGraph11.add(edgeBetweenZandG.setWeight(1)); - edgesForGraph11.add(edgeBetweenFandB.setWeight(1)); - edgesForGraph11.add(edgeBetweenDandC.setWeight(1)); - edgesForGraph11.add(edgeBetweenEandD.setWeight(1)); - edgesForGraph11.add(edgeBetweenDandF.setWeight(1)); - DirectedWeightedGraph11 = new Graph(nodesForUndirectedUnweightedGraph2, edgesForGraph11, true); - DirectedWeightedGraph11.setWeighted(true); - - // - // Graph #11: directed and weighted - // - - /* - * graph 9 but weighted - * 12 edges - * a-b - * b-c - * c-e - * e-d - * g-d - * g-a - * z-g - * h-z - * f-h - * d-f - * e-z - * f-a - * - */ - List edgesForGraph12 = new LinkedList(); - edgesForGraph12.add(edgeBetweenAandB.setWeight(1)); - edgesForGraph12.add(edgeBetweenBandC.setWeight(1)); - edgesForGraph12.add(edgeBetweenCandE.setWeight(1)); - edgesForGraph12.add(edgeBetweenEandZ.setWeight(1)); - edgesForGraph12.add(edgeBetweenEandD.setWeight(2)); - edgesForGraph12.add(edgeBetweenGandD.setWeight(2)); - edgesForGraph12.add(edgeBetweenZandG.setWeight(1)); - edgesForGraph12.add(edgeBetweenHandZ.setWeight(1)); - edgesForGraph12.add(edgeBetweenFandH.setWeight(1)); - edgesForGraph12.add(edgeBetweenDandF.setWeight(1)); - edgesForGraph12.add(edgeBetweenGandA.setWeight(1)); - edgesForGraph12.add(edgeBetweenFandA.setWeight(1)); - DirectedWeightedGraph12 = new Graph(nodesForUndirectedUnweightedGraph2, edgesForGraph12, true); - DirectedWeightedGraph12.setWeighted(true); - - // - // Graph #12: directed and weighted - // - - - /* - * graph 10 but weighted - * 10 edges - * a-d - * a-c - * d-c - * z-c - * g-e - * e-b - * b-f - * f-h - * d-z - * g-a - * - */ - - List edgesForGraph13 = new LinkedList(); - edgesForGraph13.add(edgeBetweenAandD.setWeight(1)); - edgesForGraph13.add(edgeBetweenAandC.setWeight(1)); - edgesForGraph13.add(edgeBetweenDandC.setWeight(1)); - edgesForGraph13.add(edgeBetweenBandF.setWeight(1)); - edgesForGraph13.add(edgeBetweenFandH.setWeight(1)); - edgesForGraph13.add(edgeBetweenZandC.setWeight(1)); - edgesForGraph13.add(edgeBetweenGandE.setWeight(2)); - edgesForGraph13.add(edgeBetweenEandB.setWeight(1)); - edgesForGraph13.add(edgeBetweenDandZ.setWeight(1)); - edgesForGraph13.add(edgeBetweenGandA.setWeight(1)); - - - DirectedWeightedGraph13 = new Graph(nodesForUndirectedUnweightedGraph2, edgesForGraph13, true); - DirectedWeightedGraph13.setWeighted(true); - - // - // Graph #13: directed and weighted - // - - - } - - @Test - public void depthFirstSearchUndirectedUnweightedGraph01() throws Exception { - List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph1, nodeA, nodeF); - Assert.assertEquals(path.size(), 6); - Assert.assertTrue(path.get(0).getValue().equals("A")); - Assert.assertTrue(path.get(1).getValue().equals("B")); - Assert.assertTrue(path.get(2).getValue().equals("C")); - Assert.assertTrue(path.get(3).getValue().equals("D")); - Assert.assertTrue(path.get(4).getValue().equals("E")); - Assert.assertTrue(path.get(5).getValue().equals("F")); - } - - @Test - public void depthFirstSearchRecursiveUndirectedUnweightedGraph01() throws Exception { - List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph1, nodeA, nodeF); - Assert.assertEquals(path.size(), 6); - Assert.assertTrue(path.get(0).getValue().equals("A")); - Assert.assertTrue(path.get(1).getValue().equals("B")); - Assert.assertTrue(path.get(2).getValue().equals("C")); - Assert.assertTrue(path.get(3).getValue().equals("D")); - Assert.assertTrue(path.get(4).getValue().equals("E")); - Assert.assertTrue(path.get(5).getValue().equals("F")); - } - - @Test - public void breadthFirstSearchUndirectedUnweightedGraph01() throws Exception { - List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph1, nodeA, nodeF); - Assert.assertEquals(path.size(), 6); - Assert.assertTrue(path.get(0).getValue().equals("A")); - Assert.assertTrue(path.get(1).getValue().equals("B")); - Assert.assertTrue(path.get(2).getValue().equals("C")); - Assert.assertTrue(path.get(3).getValue().equals("D")); - Assert.assertTrue(path.get(4).getValue().equals("E")); - Assert.assertTrue(path.get(5).getValue().equals("F")); - } - - @Test - public void depthFirstSearchUndirectedUnweightedGraph02() throws Exception { - List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph2, nodeA, nodeH); - Assert.assertEquals(path.size(), 8); - Assert.assertTrue(path.get(0).getValue().equals("A")); - Assert.assertTrue(path.get(1).getValue().equals("B")); - Assert.assertTrue(path.get(2).getValue().equals("C")); - Assert.assertTrue(path.get(3).getValue().equals("D")); - Assert.assertTrue(path.get(4).getValue().equals("E")); - Assert.assertTrue(path.get(5).getValue().equals("F")); - Assert.assertTrue(path.get(6).getValue().equals("G")); - Assert.assertTrue(path.get(7).getValue().equals("H")); - } - - @Test - public void depthFirstSearchRecursiveUndirectedUnweightedGraph02() throws Exception { - List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph2, nodeA, nodeH); - Assert.assertEquals(path.size(), 8); - Assert.assertTrue(path.get(0).getValue().equals("A")); - Assert.assertTrue(path.get(1).getValue().equals("B")); - Assert.assertTrue(path.get(2).getValue().equals("C")); - Assert.assertTrue(path.get(3).getValue().equals("D")); - Assert.assertTrue(path.get(4).getValue().equals("E")); - Assert.assertTrue(path.get(5).getValue().equals("F")); - Assert.assertTrue(path.get(6).getValue().equals("G")); - Assert.assertTrue(path.get(7).getValue().equals("H")); - } - - @Test - public void breadthFirstSearchUndirectedUnweightedGraph02() throws Exception { - List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph2, nodeA, nodeH); - Assert.assertEquals(path.size(), 3); - Assert.assertTrue(path.get(0).getValue().equals("A")); - Assert.assertTrue(path.get(1).getValue().equals("Z")); - Assert.assertTrue(path.get(2).getValue().equals("H")); - } - - @Test - public void depthFirstSearchUndirectedUnweightedGraph03() throws Exception { - List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph3, nodeB, nodeE); - Assert.assertEquals(path.size(), 6); - Assert.assertTrue(path.get(0).getValue().equals("B")); - Assert.assertTrue(path.get(1).getValue().equals("C")); - Assert.assertTrue(path.get(2).getValue().equals("D")); - Assert.assertTrue(path.get(3).getValue().equals("H")); - Assert.assertTrue(path.get(4).getValue().equals("Z")); - Assert.assertTrue(path.get(5).getValue().equals("E")); - } - - @Test - public void depthFirstSearchRecursiveUndirectedUnweightedGraph03() throws Exception { - List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph3, nodeB, nodeE); - Assert.assertEquals(path.size(), 6); - Assert.assertTrue(path.get(0).getValue().equals("B")); - Assert.assertTrue(path.get(1).getValue().equals("C")); - Assert.assertTrue(path.get(2).getValue().equals("D")); - Assert.assertTrue(path.get(3).getValue().equals("H")); - Assert.assertTrue(path.get(4).getValue().equals("Z")); - Assert.assertTrue(path.get(5).getValue().equals("E")); - } - - @Test - public void breadthFirstSearchUndirectedUnweightedGraph03() throws Exception { - List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph3, nodeB, nodeE); - Assert.assertEquals(path.size(), 5); - Assert.assertTrue(path.get(0).getValue().equals("B")); - Assert.assertTrue(path.get(1).getValue().equals("D")); - Assert.assertTrue(path.get(2).getValue().equals("H")); - Assert.assertTrue(path.get(3).getValue().equals("Z")); - Assert.assertTrue(path.get(4).getValue().equals("E")); - } - - @Test - public void depthFirstSearchUndirectedUnweightedGraph04() throws Exception { - List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph4, nodeB, nodeF); - Assert.assertEquals(path.size(), 7); - Assert.assertTrue(path.get(0).getValue().equals("B")); - Assert.assertTrue(path.get(1).getValue().equals("E")); - Assert.assertTrue(path.get(2).getValue().equals("G")); - Assert.assertTrue(path.get(3).getValue().equals("H")); - Assert.assertTrue(path.get(4).getValue().equals("D")); - Assert.assertTrue(path.get(5).getValue().equals("C")); - Assert.assertTrue(path.get(6).getValue().equals("F")); - } - - @Test - public void depthFirstSearchRecursiveUndirectedUnweightedGraph04() throws Exception { - List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph4, nodeB, nodeF); - Assert.assertEquals(path.size(), 7); - Assert.assertTrue(path.get(0).getValue().equals("B")); - Assert.assertTrue(path.get(1).getValue().equals("E")); - Assert.assertTrue(path.get(2).getValue().equals("G")); - Assert.assertTrue(path.get(3).getValue().equals("H")); - Assert.assertTrue(path.get(4).getValue().equals("D")); - Assert.assertTrue(path.get(5).getValue().equals("C")); - Assert.assertTrue(path.get(6).getValue().equals("F")); - } - - @Test - public void breadthFirstSearchUndirectedUnweightedGraph04() throws Exception { - List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph4, nodeB, nodeF); - Assert.assertEquals(path.size(), 4); - Assert.assertTrue(path.get(0).getValue().equals("B")); - Assert.assertTrue(path.get(1).getValue().equals("H")); - Assert.assertTrue(path.get(2).getValue().equals("D")); - Assert.assertTrue(path.get(3).getValue().equals("F")); - } - - @Test - public void depthFirstSearchUndirectedUnweightedGraph05() throws Exception { - List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph5, nodeA, nodeZ); - Assert.assertEquals(path.size(), 0); - } - - @Test - public void depthFirstSearchRecursiveUndirectedUnweightedGraph05() throws Exception { - List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph5, nodeA, nodeZ); - Assert.assertEquals(path.size(), 0); - } - - @Test - public void breadthFirstSearchUndirectedUnweightedGraph05() throws Exception { - List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph5, nodeA, nodeZ); - Assert.assertEquals(path.size(), 0); - } - - @Test - public void depthFirstSearchUndirectedUnweightedGraph06() throws Exception { - List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph6, nodeA, nodeF); - Assert.assertEquals(path.size(), 6); - } - - @Test - public void depthFirstSearchRecursiveUndirectedUnweightedGraph06() throws Exception { - List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph6, nodeA, nodeF); - Assert.assertEquals(path.size(), 6); - } - - @Test - public void breadthFirstSearchUndirectedUnweightedGraph06() throws Exception { - List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph6, nodeA, nodeF); - Assert.assertEquals(path.size(), 2); - Assert.assertTrue(path.get(0).getValue().equals("A")); - Assert.assertTrue(path.get(1).getValue().equals("F")); - } - - @Test - public void depthFirstSearchUndirectedUnweightedGraph07() throws Exception { - List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph7, nodeA, nodeF); - Assert.assertEquals(path.size(), 6); - } - - @Test - public void depthFirstSearchRecursiveUndirectedUnweightedGraph07() throws Exception { - List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph7, nodeA, nodeF); - Assert.assertEquals(path.size(), 6); - } - - @Test - public void breadthFirstSearchUndirectedUnweightedGraph07() throws Exception { - List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph7, nodeA, nodeF); - Assert.assertEquals(path.size(), 4); - Assert.assertTrue(path.get(0).getValue().equals("A")); - Assert.assertTrue(path.get(1).getValue().equals("E")); - Assert.assertTrue(path.get(2).getValue().equals("D")); - Assert.assertTrue(path.get(3).getValue().equals("F")); - } - - @Test - public void depthFirstSearchNullStartNode() throws Exception { - thrown.expect(IllegalArgumentException.class); - List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph5, null, nodeZ); - // the expect message is thrown if the thrown var doesnt catch it's appropriate exception? - // ie this message doesn't need to match the message of the thrown exception in GraphSearch.java, correct? - thrown.expectMessage("expect message"); - } - - @Test - public void depthFirstSearchRecursiveNullStartNode() throws Exception { - thrown.expect(IllegalArgumentException.class); - List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph5, null, nodeZ); - thrown.expectMessage("expect message"); - } - - @Test - public void breadthFirstSearchNullStartNode() throws Exception { - thrown.expect(IllegalArgumentException.class); - List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph5, null, nodeZ); - thrown.expectMessage("expect message"); - } - - @Test - public void depthFirstSearchNullFinishNode() throws Exception { - thrown.expect(IllegalArgumentException.class); - List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph5, nodeA, null); - // the expect message is thrown if the thrown var doesnt catch it's appropriate exception? - // ie this message doesn't need to match the message of the thrown exception in GraphSearch.java, correct? - thrown.expectMessage("expect message"); - } - - @Test - public void depthFirstSearchRecursiveNullFinishNode() throws Exception { - thrown.expect(IllegalArgumentException.class); - List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph5, nodeA, null); - thrown.expectMessage("expect message"); - } - - @Test - public void breadthFirstSearchNullFinishNode() throws Exception { - thrown.expect(IllegalArgumentException.class); - List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph5, nodeA, null); - thrown.expectMessage("expect message"); - } - - @Test - public void depthFirstSearchOutFinishNode() throws Exception { - List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph1, nodeA, nodeZ); - Assert.assertEquals(path.size(), 0); - } - - @Test - public void depthFirstSearchRecursiveOutFinishNode() throws Exception { - List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph1, nodeA, nodeZ); - Assert.assertEquals(path.size(), 0); - } - - @Test - public void breadthFirstSearchOutFinishNode() throws Exception { - List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph1, nodeA, nodeZ); - Assert.assertEquals(path.size(), 0); - } - - @Test - public void depthFirstSearchOutStartNode() throws Exception { - List path = GraphSearch.depthFirstSearch(UndirectedUnweightedgraph1, nodeZ, nodeA); - Assert.assertEquals(path.size(), 0); - } - - @Test - public void depthFirstSearchRecursiveOutStartNode() throws Exception { - List path = GraphSearch.depthFirstSearchRecursive(UndirectedUnweightedgraph1, nodeZ, nodeA); - Assert.assertEquals(path.size(), 0); - } - - @Test - public void breadthFirstSearchOutStartNode() throws Exception { - List path = GraphSearch.breadthFirstSearch(UndirectedUnweightedgraph1, nodeZ, nodeA); - Assert.assertEquals(path.size(), 0); - } - - @Test - public void depthFirstSearchNullGraph() throws Exception { - thrown.expect(IllegalArgumentException.class); - List path = GraphSearch.depthFirstSearch(null, nodeA, nodeZ); - thrown.expectMessage("expect message"); - } - - @Test - public void depthFirstSearchRecursiveNullGraph() throws Exception { - thrown.expect(IllegalArgumentException.class); - List path = GraphSearch.depthFirstSearchRecursive(null, nodeA, nodeZ); - thrown.expectMessage("expect message"); - } - - @Test - public void breadthFirstSearchNullGraph() throws Exception { - thrown.expect(IllegalArgumentException.class); - List path = GraphSearch.breadthFirstSearch(null, nodeA, nodeZ); - thrown.expectMessage("expect message"); - } - - @Test - public void depthFirstSearchEmptyGraph() throws Exception { - thrown.expect(IllegalArgumentException.class); - List path = GraphSearch.depthFirstSearch(new Graph(), nodeA, nodeZ); - thrown.expectMessage("expect message"); - } - - @Test - public void depthFirstSearchRecursiveEmptyGraph() throws Exception { - thrown.expect(IllegalArgumentException.class); - List path = GraphSearch.depthFirstSearchRecursive(new Graph(), nodeA, nodeZ); - thrown.expectMessage("expect message"); - } - - @Test - public void breadthFirstSearchEmptyGraph() throws Exception { - thrown.expect(IllegalArgumentException.class); - List path = GraphSearch.breadthFirstSearch(new Graph(), nodeA, nodeZ); - thrown.expectMessage("expect message"); - } - - @Test - public void depthFirstSearchDirectedUnweightedGraph08() throws Exception { - List path = GraphSearch.depthFirstSearch(DirectedUnweightedGraph8, nodeH, nodeB); - Assert.assertEquals(path.size(), 6); - Assert.assertTrue(path.get(0).getValue().equals("H")); - Assert.assertTrue(path.get(1).getValue().equals("Z")); - Assert.assertTrue(path.get(2).getValue().equals("G")); - Assert.assertTrue(path.get(3).getValue().equals("D")); - Assert.assertTrue(path.get(4).getValue().equals("F")); - Assert.assertTrue(path.get(5).getValue().equals("B")); - } - - @Test - public void depthFirstSearchRecursiveDirectedUnweightedGraph08() throws Exception { - List path = GraphSearch.depthFirstSearchRecursive(DirectedUnweightedGraph8, nodeH, nodeB); - Assert.assertEquals(path.size(), 6); - Assert.assertTrue(path.get(0).getValue().equals("H")); - Assert.assertTrue(path.get(1).getValue().equals("Z")); - Assert.assertTrue(path.get(2).getValue().equals("G")); - Assert.assertTrue(path.get(3).getValue().equals("D")); - Assert.assertTrue(path.get(4).getValue().equals("F")); - Assert.assertTrue(path.get(5).getValue().equals("B")); - } - - @Test - public void breadthFirstSearchDirectedUnweightedGraph08() throws Exception { - List path = GraphSearch.breadthFirstSearch(DirectedUnweightedGraph8, nodeH, nodeB); - Assert.assertEquals(path.size(), 5); - Assert.assertTrue(path.get(0).getValue().equals("H")); - Assert.assertTrue(path.get(1).getValue().equals("Z")); - Assert.assertTrue(path.get(2).getValue().equals("D")); - Assert.assertTrue(path.get(3).getValue().equals("F")); - Assert.assertTrue(path.get(4).getValue().equals("B")); - } - - @Test - public void depthFirstSearchDirectedUnweightedGraph09() throws Exception { - List path = GraphSearch.depthFirstSearch(DirectedUnweightedGraph9, nodeE, nodeF); - Assert.assertEquals(path.size(), 5); - Assert.assertTrue(path.get(0).getValue().equals("E")); - Assert.assertTrue(path.get(1).getValue().equals("Z")); - Assert.assertTrue(path.get(2).getValue().equals("G")); - Assert.assertTrue(path.get(3).getValue().equals("D")); - Assert.assertTrue(path.get(4).getValue().equals("F")); - } - - @Test - public void depthFirstSearchRecursiveDirectedUnweightedGraph09() throws Exception { - List path = GraphSearch.depthFirstSearchRecursive(DirectedUnweightedGraph9, nodeE, nodeF); - Assert.assertEquals(path.size(), 5); - Assert.assertTrue(path.get(0).getValue().equals("E")); - Assert.assertTrue(path.get(1).getValue().equals("Z")); - Assert.assertTrue(path.get(2).getValue().equals("G")); - Assert.assertTrue(path.get(3).getValue().equals("D")); - Assert.assertTrue(path.get(4).getValue().equals("F")); - } - - @Test - public void breadthFirstSearchDirectedUnweightedGraph09() throws Exception { - List path = GraphSearch.breadthFirstSearch(DirectedUnweightedGraph9, nodeE, nodeF); - Assert.assertEquals(path.size(), 3); - Assert.assertTrue(path.get(0).getValue().equals("E")); - Assert.assertTrue(path.get(1).getValue().equals("D")); - Assert.assertTrue(path.get(2).getValue().equals("F")); - } - - @Test - public void depthFirstSearchDirectedUnweightedGraph10() throws Exception { - List path = GraphSearch.depthFirstSearch(DirectedUnweightedGraph10, nodeG, nodeH); - Assert.assertEquals(path.size(), 5); - Assert.assertTrue(path.get(0).getValue().equals("G")); - Assert.assertTrue(path.get(1).getValue().equals("E")); - Assert.assertTrue(path.get(2).getValue().equals("B")); - Assert.assertTrue(path.get(3).getValue().equals("F")); - Assert.assertTrue(path.get(4).getValue().equals("H")); - } - - @Test - public void depthFirstSearchRecursiveDirectedUnweightedGraph10() throws Exception { - List path = GraphSearch.depthFirstSearchRecursive(DirectedUnweightedGraph10, nodeG, nodeH); - Assert.assertEquals(path.size(), 5); - Assert.assertTrue(path.get(0).getValue().equals("G")); - Assert.assertTrue(path.get(1).getValue().equals("E")); - Assert.assertTrue(path.get(2).getValue().equals("B")); - Assert.assertTrue(path.get(3).getValue().equals("F")); - Assert.assertTrue(path.get(4).getValue().equals("H")); - } - - @Test - public void breadthFirstSearchDirectedUnweightedGraph10() throws Exception { - List path = GraphSearch.breadthFirstSearch(DirectedUnweightedGraph10, nodeG, nodeH); - Assert.assertEquals(path.size(), 5); - Assert.assertTrue(path.get(0).getValue().equals("G")); - Assert.assertTrue(path.get(1).getValue().equals("E")); - Assert.assertTrue(path.get(2).getValue().equals("B")); - Assert.assertTrue(path.get(3).getValue().equals("F")); - Assert.assertTrue(path.get(4).getValue().equals("H")); - } - - @Test - public void depthFirstSearchDirectedWeightedGraph11() throws Exception { - List path = GraphSearch.depthFirstSearch(DirectedWeightedGraph11, nodeH, nodeB); - Assert.assertEquals(path.size(), 6); - Assert.assertTrue(path.get(0).getValue().equals("H")); - Assert.assertTrue(path.get(1).getValue().equals("Z")); - Assert.assertTrue(path.get(2).getValue().equals("G")); - Assert.assertTrue(path.get(3).getValue().equals("D")); - Assert.assertTrue(path.get(4).getValue().equals("F")); - Assert.assertTrue(path.get(5).getValue().equals("B")); - } - - @Test - public void depthFirstSearchRecursiveDirectedWeightedGraph11() throws Exception { - List path = GraphSearch.depthFirstSearchRecursive(DirectedWeightedGraph11, nodeH, nodeB); - Assert.assertEquals(path.size(), 6); - Assert.assertTrue(path.get(0).getValue().equals("H")); - Assert.assertTrue(path.get(1).getValue().equals("Z")); - Assert.assertTrue(path.get(2).getValue().equals("G")); - Assert.assertTrue(path.get(3).getValue().equals("D")); - Assert.assertTrue(path.get(4).getValue().equals("F")); - Assert.assertTrue(path.get(5).getValue().equals("B")); - } - - @Test - public void breadthFirstSearchDirectedWeightedGraph11() throws Exception { - List path = GraphSearch.breadthFirstSearch(DirectedWeightedGraph11, nodeH, nodeB); - Assert.assertEquals(path.size(), 5); - Assert.assertTrue(path.get(0).getValue().equals("H")); - Assert.assertTrue(path.get(1).getValue().equals("Z")); - Assert.assertTrue(path.get(2).getValue().equals("D")); - Assert.assertTrue(path.get(3).getValue().equals("F")); - Assert.assertTrue(path.get(4).getValue().equals("B")); - } - - @Test - public void depthFirstSearchDirectedWeightedGraph12() throws Exception { - List path = GraphSearch.depthFirstSearch(DirectedWeightedGraph12, nodeE, nodeF); - Assert.assertEquals(path.size(), 5); - Assert.assertTrue(path.get(0).getValue().equals("E")); - Assert.assertTrue(path.get(1).getValue().equals("Z")); - Assert.assertTrue(path.get(2).getValue().equals("G")); - Assert.assertTrue(path.get(3).getValue().equals("D")); - Assert.assertTrue(path.get(4).getValue().equals("F")); - } - - @Test - public void depthFirstSearchRecursiveDirectedWeightedGraph12() throws Exception { - List path = GraphSearch.depthFirstSearchRecursive(DirectedWeightedGraph12, nodeE, nodeF); - Assert.assertEquals(path.size(), 5); - Assert.assertTrue(path.get(0).getValue().equals("E")); - Assert.assertTrue(path.get(1).getValue().equals("Z")); - Assert.assertTrue(path.get(2).getValue().equals("G")); - Assert.assertTrue(path.get(3).getValue().equals("D")); - Assert.assertTrue(path.get(4).getValue().equals("F")); - } - - @Test - public void breadthFirstSearchDirectedWeightedGraph12() throws Exception { - List path = GraphSearch.breadthFirstSearch(DirectedWeightedGraph12, nodeE, nodeF); - Assert.assertEquals(path.size(), 3); - Assert.assertTrue(path.get(0).getValue().equals("E")); - Assert.assertTrue(path.get(1).getValue().equals("D")); - Assert.assertTrue(path.get(2).getValue().equals("F")); - } - - @Test - public void depthFirstSearchDirectedWeightedGraph13() throws Exception { - List path = GraphSearch.depthFirstSearch(DirectedWeightedGraph13, nodeG, nodeH); - Assert.assertEquals(path.size(), 5); - Assert.assertTrue(path.get(0).getValue().equals("G")); - Assert.assertTrue(path.get(1).getValue().equals("E")); - Assert.assertTrue(path.get(2).getValue().equals("B")); - Assert.assertTrue(path.get(3).getValue().equals("F")); - Assert.assertTrue(path.get(4).getValue().equals("H")); - } - - @Test - public void depthFirstSearchRecursiveDirectedWeightedGraph13() throws Exception { - List path = GraphSearch.depthFirstSearchRecursive(DirectedWeightedGraph13, nodeG, nodeH); - Assert.assertEquals(path.size(), 5); - Assert.assertTrue(path.get(0).getValue().equals("G")); - Assert.assertTrue(path.get(1).getValue().equals("E")); - Assert.assertTrue(path.get(2).getValue().equals("B")); - Assert.assertTrue(path.get(3).getValue().equals("F")); - Assert.assertTrue(path.get(4).getValue().equals("H")); - } - - @Test - public void breadthFirstSearchDirectedWeightedGraph13() throws Exception { - List path = GraphSearch.breadthFirstSearch(DirectedWeightedGraph13, nodeG, nodeH); - Assert.assertEquals(path.size(), 5); - Assert.assertTrue(path.get(0).getValue().equals("G")); - Assert.assertTrue(path.get(1).getValue().equals("E")); - Assert.assertTrue(path.get(2).getValue().equals("B")); - Assert.assertTrue(path.get(3).getValue().equals("F")); - Assert.assertTrue(path.get(4).getValue().equals("H")); - } - - // same as graph 13, except start at e and look for c, un connected, will need to restart - @Test - public void depthFirstSearchDirectedWeightedGraph14() throws Exception { - List path = GraphSearch.depthFirstSearch(DirectedWeightedGraph13, nodeE, nodeC); - Assert.assertEquals(path.size(), 0); - } - - @Test - public void depthFirstSearchRecursiveDirectedWeightedGraph14() throws Exception { - List path = GraphSearch.depthFirstSearchRecursive(DirectedWeightedGraph13, nodeE, nodeC); - Assert.assertEquals(path.size(), 0); - } - - @Test - public void breadthFirstSearchDirectedWeightedGraph14() throws Exception { - List path = GraphSearch.breadthFirstSearch(DirectedWeightedGraph13, nodeE, nodeC); - Assert.assertEquals(path.size(), 0); - } - -} \ No newline at end of file