-- Copyright 2003, Trustees of Indiana University -- Please see the license in the file ../LICENSE class TEST_PRIM 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] prim : PRIM_MINIMUM_SPANNING_TREE[INTEGER, BASIC_EDGE, ADJACENCY_LIST, REAL] compare: LT_COMPARE[REAL] i : INTEGER test_graph_creator : CREATE_TEST_GRAPH output : OUTPUT_GRAPH[INTEGER, BASIC_EDGE, ADJACENCY_LIST] tmp_edge : BASIC_EDGE total_length : REAL do create pred_map.make create distance_map.make create compare create test_graph_creator create output g := test_graph_creator.graph weight_map := test_graph_creator.weights output.print_weights(g, weight_map) io.put_string("%NRunning Prim from vertex 0.%N") create prim prim.go(g, 0, pred_map, distance_map, weight_map, compare, inf, 0) io.put_string("The resulting predecessor map:%N") total_length := 0.0 from i := 0 until i = g.num_vertices loop io.put_string(i.out + ": " + pred_map.get(i).out) io.put_string("%N") create tmp_edge.make(pred_map.get(i), i) total_length := total_length + weight_map.get(tmp_edge) i := i + 1 end io.put_string("Total length: " + total_length.out + "%N%N") Result := true end end -- TEST_PRIM