with graph; with ada.text_io; with ada.integer_text_io; procedure Graph_Driver is Max_Cities : constant := 20; type City is (atlanta, boston, chicago, dallas, great_falls, houston, ithaca, jacksonville, kansas_city, lexington, minneapolis, new_york, oswego, philadelphia, quogue, talahassee, utica, venice, washington, yonkers); subtype Distance is natural; package City_IO is new ada.text_io.enumeration_io (city); function cityName(location : in city) return City is begin return location; end cityName; package Routes is new graph( vertex_type => city, key_type => city, weight_type => distance, key_of => cityName, "=" => "="); myGraph : Routes.Graph_Type(Max_Cities); leg : Routes.Edge_Type; myCity: city; myweight : distance; neighbors : Routes.Key_Queue.Queue_Type(Max_Size => Max_Cities); -- from page 738 begin Routes.Clear(Graph => myGraph); -- initialize graph to have no nodes and no edges in it Routes.Add_Vertex (Graph => myGraph, Vertex => new_york); -- add vertex Routes.Add_Vertex (Graph => myGraph, Vertex => boston); -- add vertex leg := (from => new_york, to => boston); -- specify direction of edge Routes.Add_Edge (Graph => myGraph, Edge => leg, weight => 188); -- add edge Routes.retrieve (Graph => myGraph, Key => boston, Vertex => myCity); -- existence test city_io.put (myCity); myWeight := Routes.Weight_of(Graph => myGraph, Edge => leg); -- retrieve distance ada.integer_text_io.put (myWeight); ada.text_io.new_line; Routes.Add_Vertex (Graph => myGraph, Vertex => Philadelphia); leg := (from => new_york, to => philadelphia ); Routes.Add_Edge (Graph => myGraph, Edge => leg, weight => 125); Routes.get_Adjacent_Vertices (Graph => myGraph, Key => new_york, Adj_keys => neighbors); while not Neighbors.empty loop neighbors.dequeue (myCity); city_io.put (myCity,10); end loop; end Graph_Driver;