def test_parse(self): solution = parse("sample.gpx") if type(solution) != list: self.fail("The given solution is not of type list!") print(solution)
def test_create_cut_between_dir_graphs(self): point1 = Point(1, 2) point2 = Point(1, 3) point3 = Point(1, 4) point4 = Point(4, 4) epsilon = 0.5 graph1: directedGraph = buildGraph([point1, point2, point3, point4], epsilon) graph2: directedGraph = buildGraph([point4, point3, point2, point1], epsilon) cutGraph = createCutBetweenDirGraphs(graph1, graph2) if len(cutGraph.getAllNodes()) != 4: self.fail("The cut graph should have exactly four nodes!") # -- points: [Point] = parse("sample.gpx") epsilon = 0.0005 graph1: directedGraph = buildGraph(points, epsilon) # reverse the order of the points to build an inverse graph points.reverse() graph2: directedGraph = buildGraph(points, epsilon) cutGraph = createCutBetweenDirGraphs(graph1, graph2) shortestPath = cutGraph.findShortestPath() print(len(cutGraph.getAllNodes()))
def test_build_graph(self): points = parse("sample.gpx") epsilon = 0.119 graph: directedGraph = buildGraph(points, epsilon) if graph is None: self.fail("None was returned!") if len(graph.getAllNodes()) == 0: self.fail("The graph is empty and does not contain any nodes.")
def test_build_directed_graph(self): listOfPoints = parse("sample.gpx") graph = buildDirectedGraph(listOfPoints) if len(graph.getAllNodes()) == 0: self.fail( "No nodes were added to the list of all nodes while creating a directed graph ..." )
def test_get_shortest_path(self): points = parse("sample.gpx") epsilon = 0.00001 graph = buildDirectedGraph(points) reducedGraph: directedGraph = removeEdges(graph, epsilon) shortestPath: list[node] = getShortestPath(reducedGraph) if type(shortestPath) != list and not shortestPath is None: self.fail("The returned value is not of type list. It is: " + str(type(shortestPath))) if len(shortestPath) == 0: self.fail("The returned variable does not contain any objects ...")
def test_remove_edges(self): points = parse("sample.gpx") epsilon = 0.0001 graph = buildDirectedGraph(points) reducedGraph: directedGraph = removeEdges(graph, epsilon) if reducedGraph is None: self.fail("The returned graph is None ...") if len(reducedGraph.getAllNodes()) == 0: self.fail("While reducing the graph, no nodes were left ...") if len(graph.getAllNodes()[0].getAllSuccessor()) == len( reducedGraph.getAllNodes()[0].getAllSuccessor()): self.fail("The reduction of the graph did not work ...")