/* File: graph.h
 *
 * The class/interface for a graph object.
 */

class Graph {
    public:
               // adds and edge from x to y with the specified length
        void add_edge(int x, int y, int length);

               // returns true if there is an edge from x to y
        bool is_adjacent(int x, int y);

               // returns the length of the edge from x to y
        int edge_length(int x, int y);

               // returns the number of vertices of the graph
        int size() { return num_vertices; }

               // thrown if a method above is called with an illegal vertex
        class Bad_vertex { };

               // thrown if the edge_length function is called without an edge
        class No_edge { };

               // constructor: graph must be initialized with # of nodes
        Graph(int size);
        ~Graph();

    private:
        bool **matrix;                      // the adjacency matrix data
        int **lengths;                      // a matrix of lengths
        int num_vertices;                   // the number of vertices

        bool not_a_vertex(int x);           // tests whether x is a legal node
};


