Write a suitable declaration for a graph ADT interface that can be used to study graph algorithms

Source Code

Brief explanation is provided after the source code.

/*
    Graph ADT interface (graph.h)
*/
typedef struct { int v; int w; } Edge;
Edge EDGE(int, int);
typedef struct graph *Graph; /* implementation of struct graph varies */
Graph GraphInit(int);
void GraphInsertE(Graph, Edge);
void GraphRemoveE(Graph, Edge);
int GraphEdges(Edge[], Graph G);    /* extract the set of edges in an array */

Brief Explanation

  • Simple interface that can be used to study graphs algorithms.
  • Data type Edge represents an edge (i.e a vertex pair)
  • Function EDGE takes an integer pair representing two vertex values, and makes and return an edge from them. User defined data type Graph is a pointer to a graph data structure, which is implementation-dependent.
  • Functions GraphInit, GraphInsertE, and GraphRemoveE respectively initializes the graph, inserts an edge, and removes an edge, while function GraphEdges extracts the set of edges in an array.

Add comment


Security code
Refresh