-- Copyright 2003, Trustees of Indiana University -- Please see the license in the file ../LICENSE class TEST_BELLMAN_FORD feature inf : REAL is 99999999999999999999.9 -- INFINITY test : BOOLEAN is local g: ADJACENCY_LIST pred_map : HASH_PROPERTY_MAP[INTEGER, INTEGER] distance_map : HASH_PROPERTY_MAP[INTEGER, REAL] weight_map : HASH_PROPERTY_MAP[BASIC_EDGE, REAL] bellman_ford : BELLMAN_FORD_SHORTEST_PATH[INTEGER, BASIC_EDGE, REAL, ADJACENCY_LIST] compare: LT_COMPARE[REAL] combine: PLUS[REAL] i : INTEGER test_graph_creator : CREATE_TEST_GRAPH output : OUTPUT_GRAPH[INTEGER, BASIC_EDGE, ADJACENCY_LIST] do create pred_map.make create distance_map.make create compare create combine create test_graph_creator g := test_graph_creator.graph weight_map := test_graph_creator.weights -- print out the graph create output output.print_weights(g, weight_map) distance_map.put(0, 0.0) distance_map.put(1, inf) distance_map.put(2, inf) distance_map.put(3, inf) distance_map.put(4, inf) distance_map.put(5, inf) distance_map.put(6, inf) distance_map.put(7, inf) io.put_string("%NRunning Bellman-Ford from vertex 0.%N") create bellman_ford Result := bellman_ford.go(g, 8, weight_map, pred_map, distance_map, combine, compare) io.put_string("%NThe resulting pred map:%N") from i := 0 until i = g.num_vertices loop io.put_string(i.out + ": " + pred_map.get(i).out) io.put_string("%N") i := i + 1 end io.put_string("%N%N") -- Result := true end end -- TEST_BELLMAN_FORD