diff --git a/Projektgruppe_175/src/base/Graph.java b/Projektgruppe_175/src/base/Graph.java index b979fa4..5f6be17 100644 --- a/Projektgruppe_175/src/base/Graph.java +++ b/Projektgruppe_175/src/base/Graph.java @@ -131,7 +131,8 @@ public class Graph { * @return true, wenn alle Knoten erreichbar sind */ public boolean allNodesConnected() { - // TODO: Graph#allNodesConnected() + return false; + } } diff --git a/Projektgruppe_175/src/tests/student/GraphConnectionTest.java b/Projektgruppe_175/src/tests/student/GraphConnectionTest.java index 6c3f261..0e83499 100644 --- a/Projektgruppe_175/src/tests/student/GraphConnectionTest.java +++ b/Projektgruppe_175/src/tests/student/GraphConnectionTest.java @@ -1,5 +1,48 @@ package tests.student; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.jupiter.api.Test; + +import base.*; + public class GraphConnectionTest { + @Test + public void testCorrectGraph() { + + Graph testGraph = new Graph(); + + Node a = testGraph.addNode("A"); + Node b = testGraph.addNode("B"); + Node c = testGraph.addNode("C"); + Node d = testGraph.addNode("D"); + + testGraph.addEdge(a, b); + testGraph.addEdge(a, c); + testGraph.addEdge(c, d); + + assertTrue(testGraph.allNodesConnected()); + + } + + @Test + public void testIncorrectGraph() { + + Graph testGraph = new Graph(); + + Node one = testGraph.addNode(1); + Node two = testGraph.addNode(2); + Node four = testGraph.addNode(4); + Node seven = testGraph.addNode(7); + Node nine = testGraph.addNode(9); + + testGraph.addEdge(one, seven); + testGraph.addEdge(two, nine); + + assertFalse(testGraph.allNodesConnected()); + + } + }