def test_johnson(file, expected):
    _, graph, distances = util.get_graph(file, directed=True, offset=1)
    actual = johnson(graph, distances)
    if isinstance(actual, str):
        assert actual == expected
    else:
        min_distance = min(actual.values())
        assert min_distance == expected
Ejemplo n.º 2
0
def test_big_graph():
    nodes, graph, distances = util.get_graph(f"{RESOURCES}/edges.txt")
    mst = greedy.prim(nodes, graph, distances)
    cost = greedy.total_cost(mst, distances)
    print(f"The MST cost is {cost}")
Ejemplo n.º 3
0
def test_small_graph():
    nodes, graph, distances = util.get_graph(f"{RESOURCES}/test_edges.txt")
    mst = greedy.prim(nodes, graph, distances)
    actual = greedy.total_cost(mst, distances)
    expected = 7
    assert actual == expected
Ejemplo n.º 4
0
def test_data():
    nodes, graph, distances = util.get_graph(f"{RESOURCES}/test_edges.txt")
    assert nodes is not None
    assert graph is not None
    assert distances is not None
Ejemplo n.º 5
0
 def test_big_graph(self):
     nodes, graph, distances = get_graph(f"{RESOURCES}/edges.txt")
     mst = clusters.kruskal(nodes, distances)
     actual = clusters.total_cost(mst, distances)
     expected = -3612829
     self.assertEqual(actual, expected)
Ejemplo n.º 6
0
 def test_small_graph(self):
     nodes, _, distances = get_graph(f"{RESOURCES}/test_edges.txt")
     mst = clusters.kruskal(nodes, distances)
     actual = clusters.total_cost(mst, distances)
     expected = 7
     self.assertEqual(actual, expected)