Beispiel #1
0
 def test_find_all_paths_three_complete(self):
     graph: Graph = TraceMatrixBuilder.create_dependency_graph_with_trace_ids(
         ["0-2", "0-1", "1-2"], 3)
     paths = get_all_paths(graph, 0, 1)
     self.assertEqual(2, len(paths))
     self.assertEqual([0, 1], paths[0])
     self.assertEqual([0, 2, 1], paths[1])
Beispiel #2
0
 def test_find_all_paths_one(self):
     graph: Graph = TraceMatrixBuilder.create_dependency_graph_with_trace_ids(
         [], 1)
     paths = get_all_paths(graph, 0, 0)
     self.assertEqual(1, len(paths))
     self.assertEqual(1, len(paths[0]))
     self.assertEqual(0, paths[0][0])
Beispiel #3
0
 def test_find_all_paths_four_incomplete(self):
     traces = ["1-2", "0-2", "2-3", "1-0", "0-3", "1-3"]
     graph: Graph = TraceMatrixBuilder.create_dependency_graph_with_trace_ids(
         traces, 4)
     paths = get_all_paths(graph, 1, 2)
     self.assertEqual(5, len(paths))
     self.assertTrue([1, 0, 2] in paths)
     self.assertTrue([1, 2] in paths)
     self.assertTrue([1, 3, 2] in paths)
     self.assertTrue([1, 0, 3, 2] in paths)
     self.assertTrue([1, 3, 0, 2] in paths)
    def add_transitive_traces(self):
        """
        Calculates all transitive traces between all trace matrices and adds them to any matrices missing them.
        Transitive traces are calculated by taking the dot-product (with max aggregator instead of sum) of lists of
        trace matrices corresponding to a path in the dependency graph of between artifacts.
        :return:
        """
        graph = self.create_trace_matrix_dependency_graph()
        direct_path_map: GraphPathMap = GraphPathMap()
        for trace_id in self.trace_matrix_map.get_trace_ids():
            a_index, b_index = TraceIdMap.parse_trace_id(trace_id)
            direct_path_map[trace_id] = get_all_paths(graph, a_index, b_index)
        updated_trace_matrix_map: TraceMatrixMap = (
            self.create_transitive_trace_matrices_for_paths(direct_path_map))

        self.trace_matrix_map.update(updated_trace_matrix_map)
Beispiel #5
0
 def test_find_all_paths_three_incomplete(self):
     graph: Graph = TraceMatrixBuilder.create_dependency_graph_with_trace_ids(
         ["0-2"], 3)
     paths = get_all_paths(graph, 0, 1)
     self.assertEqual(0, len(paths))
Beispiel #6
0
 def test_find_all_paths_two_empty(self):
     graph: Graph = TraceMatrixBuilder.create_dependency_graph_with_trace_ids(
         [], 2)
     paths = get_all_paths(graph, 0, 1)
     self.assertEqual(0, len(paths))
Beispiel #7
0
 def test_find_all_paths_two_complete(self):
     graph: Graph = TraceMatrixBuilder.create_dependency_graph_with_trace_ids(
         ["0-1"], 2)
     paths = get_all_paths(graph, 0, 1)
     self.assertEqual(1, len(paths))
     self.assertEqual([0, 1], paths[0])