#pragma once #include #include #include using namespace std; class Graph { public: //n is the number of vertices //edges is a list of pairs representing the edges (default = empty list) Graph(int n, list< pair > & edges); //Default constructor creates an empty graph Graph(): n(0), m(0) {}; //Returns the number of vertices int GetNumVertices() { return n; }; //Returns the number of edges int GetNumEdges() { return m; }; //Given the edge's index, returns its endpoints as a pair pair GetEdge(int e); //Given the endpoints, returns the index int GetEdgeIndex(int u, int v); //Adds a new edge to the graph void AddEdge(int u, int v); //Returns the adjacency list of a vertex const vector& AdjList(int v); //Returns the graph's adjacency matrix const vector& AdjMat(); private: //Number of vertices int n; //Number of edges int m; //Adjacency matrix vector adjMat; //Adjacency lists vector > adjList; //Array of edges vector > edges; //Indices of the edges unordered_map edgeIndex; };