We shall define a class named Graph representing a directed graph.
We need some auxiliary clases:
The class Graph will provide the following methods:
struct Edge { // represents an arc of the graph int source; // index of source vertex int target; // index of target vertex struct Edge* next_source; // next edge from the same source struct Edge* prev_source; // previous edge from the same source struct Edge* next_target; // next edge to the same target struct Edge* prev_target; // previous edge to the same target int label; // label attached to the graph (length or so) }; struct Vertex { // represents a vertex struct Edge* first_in; // pointer to the first inbound arc; null if none struct Edge* first_out; // pointer to the first outbound arc; null if none };Each edge is member of two double-linked lists, a list of all edges that are outbound from the same vertex, and a list of all edges inbound to the same vertex. Each vertex has a pointer to one of the edges in each list.
Class Graph will have the following data members:
Edge_id and the others shall be documented here as above. Helper (private) functions may be documented here.
Radu-Lucian LUPŞA