def test(): cost = { (1,2) : 7, (1,3) : 9, (1,6) : 14, (2,4) : 15, (2,3) : 10, (6,3) : 2, (6,5) : 9, (3, 4) : 11, (5,4) : 6 } cost = graph_utils.weights(cost) g = graph_utils.make_graph(cost.keys()) dijkstra(g, cost, g.vertices[1]) for vertex in g.vertices.values(): print(vertex)
def test(): w = { (1,2) : 7, (1,3) : 9, (1,6) : 14, (2,4) : 15, (2,3) : 10, (6,3) : 2, (6,5) : 9, (3, 4) : 11, (5,4) : 6 } weights = graph.weights(w) g = graph.make_graph(w.keys()) bellman_ford(g, weights, g.vertices[1]) assert(g.vertices[1].d == 0) assert(g.vertices[2].d == 7) assert(g.vertices[3].d == 9) assert(g.vertices[4].d == 20) assert(g.vertices[5].d == 23) assert(g.vertices[6].d == 14) print('test passes')
def test_graph(cost, source): cost = graph_utils.weights(cost) g = graph_utils.make_graph(cost.keys()) dijkstra(g, cost, g.vertices[source]) for vertex in g.vertices.values(): print(vertex)