#include "graph.h" // These are the member functions for the graph class. // This is all that had to be written from scratch. // const unsigned int INFINITY = ~0; // Graph constructor. Create a graph with room for n vertices Graph::Graph(int n) { max_vertices=n; vertices=new Vertex[n]; adjacencies=new List[n]; // a list of edges pathinfo=new DTableEntry[n]; num_vertices=0; } // Given the name of a node, return its number int Graph::NameToNum(const String &s) { if (name_table.Find(s)) { return name_table.GetLastFind(); } else return NOTAVERTEX; } // Given the number of a node, return its name String Graph::NumToName(int n) { if (n>=0 && n=0 && n pathinfo[m].dist+e.distance) { pathinfo[e.node].dist=pathinfo[m].dist+ e.distance; pathinfo[e.node].path=m; } } e=NextEdge(m); } pathinfo[m].known=1; } if (pathinfo[endv].dist!=INFINITY) { cout << "The best path from " << start << " to " << end << " is\n"; print_path(endv); cout << "\nThe distance is " << pathinfo[endv].dist << endl; } else cout << "No path exists between " << start << " and " << end << endl; } void Graph::init_table(int start) { int i; for (i=0; i