Implement a graph ADT by defining a class Graph with the ope
Solution
Answer: See the code below
-------------------------------------------------
using System;
 using System.Collections.Generic;
namespace GraphADT
 {
     //Graph ADT class
     abstract class Graph
     {
         //data members
         private int nV; //number of vertices
         private int nE; //number of edges
         private int[,] adjMatrix; //adjaceny matrix for graph
         private bool directedGraph; //flag for graph being directed graph
        //constructors
         //creates a graph with zero vertices
         public Graph()
         {
             nV = 0;
             nE = 0;
             directedGraph = false;
         }
         //creates a graph with n vertices
         public Graph(int n)
         {
             nV = n;
             nE = 0;
             adjMatrix = new int[n,n];
             directedGraph = false;
         }
         //creates a digraph with n vertices
         public Graph(int n, bool digraph)
         {
             nV = n;
             nE = 0;
             adjMatrix = new int[n, n];
             directedGraph = digraph;
         }
        //methods
         //tests is the graph is a diagraph.
         public abstract bool isDirect();
         //tests whether there is an edge from vertex v to u
         public abstract bool adjacent(int u, int v);
         //returns the list of all vertices that are a destination of an edge from v.
         public abstract List<int> neighbours(int v);
         //adds the vertex v to the graph, if not already in graph, otherwise an error message is thrown.
         public abstract void addVertex(int v);
         //removes vertex v from the graph, if it is there. When a vertex is removed, all edges associated
         //with that vertex are also removed.
         public abstract void removeVertex(int v);
         //add the edge that starts from v and ends at u.
         public abstract void addEdge(int v, int u);
         //add the edge that starts from v and ends at u with weight w.
         public abstract void addEdge(int v, int u, int w);
         //returns the weight of edge from v to u.
         public abstract void getWeight(int v, int u);
         //sets the weight of edge from v to u.
         public abstract void setWeight(int v, int u);
         //checks whether graph is empty or not
         public abstract bool isEmpty();
         //checks whether the graph is complete or not
         public abstract bool isComplete();
         //returns the list of vertices in graph
         public abstract List<int> vertices();
         //returns the list of edges in the graph
         public abstract int[][] edges();
         //returns the degree of vertex v
         public abstract int degree(int v);
         //returns the number of vertices in graph
         public abstract int size();
         //returns the number of edges in graph
         public abstract int nEdges();
         //Reinitializes the graph to be empty, freeing any heap storage
         public abstract void clear();
         //tests whether a vertex is in the graph or not
         public abstract bool vertexExists(int v);
         //displays the list of vertices, edges and their weights, if the graph is weighted
         public abstract void print();
     }
}


