Class BaseGraph#
Defined in File BaseGraph.h
Nested Relationships#
Nested Types#
Inheritance Relationships#
Derived Types#
public DGraph(Class DGraph)public Graph(Class Graph)
Class Documentation#
-
class BaseGraph#
BaseGraph is the abstract base class (the “interface”) for a general graph.
It defines graph properties common to directed and undirected graphs. It leaves out some loose ends in the interface:
A node has no notion of incident edges or neighboring nodes because the number of kinds of incident edges or neighboring nodes is dependent upon the graph being directed or undirected.
For the same reason, the method delete(node) cannot delete any incident edges. Therefore the directed or undirected graph must override it with a more complete version. Similarly, the method delete(edge) cannot delete the edge from the list(s) of the nodes involved.
In an analogous manner, the method add(edge) must be overridden with a more complete version that adds the edge into the records of the nodes involved, if needed.
The only restriction on nodes and edges is that they should be unique objects, meaning, an edge or a node cannot be shared between two graphs. A node or edge can also not be inserted twice. Nodes and edges are identified by their pointer values (BaseGraph::Node* and BaseGraph::Edge*).
Following exceptions are thrown by the class (all are subclasses of Exception):
BaseGraph::EmptyEdge — attempt to add, or remove, an empty edge (null pointer)
BaseGraph::DuplicateEdge — attempt to add an edge more than once
BaseGraph::NonexistentEdge — attempt to remove an edge that does not belong to the graph
BaseGraph::EdgeInUse — attempt to add an edge that is already a part of another graph
BaseGraph::EmptyNode — attempt to add, or remove, an empty node (null pointer)
BaseGraph::DuplicateNode — attempt to add a node more than once
BaseGraph::NonexistentNode — attempt to remove a node that does not belong to the graph
BaseGraph::NodeInUse — attempt to add a node that is already a part of another graph
BaseGraph::DeletingRootOfNonSingletonGraph — attempt to delete the root node when graph has more nodes & edges
NOTE ON friend CLASSES: Many classes (especially BaseGraph, BaseGraph::Node and BaseGraph::Edge) have many friend classes. This is not a kludge. It is simulating “package” visiblity in Java. We want a limited public interface to Node and Edge and yet give more permissions to methods within the BaseGraph class.
Public Functions
-
inline BaseGraph()#
-
virtual ~BaseGraph()#
-
inline int num_nodes()#
-
inline int num_edges()#
-
inline bool isempty()#
-
void dump(std::ostream&)#
Protected Functions
Friends
- friend class DFSIterator
- friend class BFSIterator
- friend class NodesIterator
- friend class BiDirNodesIterator
- friend class EdgesIterator
-
class BFSIterator : public Iterator#
The BFSiterator calls the virtual function create_BFS_links the first time it is called, or if the graph has been changed since the last call.
Subclassed by DGraph::BFSIterator, Graph::BFSIterator
-
class BiDirNodesIterator : public Iterator#
The bi-directional node iterator iterates over all the nodes in the graph in no particular order — except that the Forward direction is guaranteed to be opposite of the Reverse direction.
Subclassed by DGraph::BiDirNodesIterator, Graph::BiDirNodesIterator
-
class DFSIterator : public Iterator#
The DFSiterator calls the virtual function create_DFS_links the first time it is called, or if the graph has been changed since the last call.
Subclassed by DGraph::DFSIterator, Graph::DFSIterator
-
class DuplicateEdge : public Exception#
DuplicateEdge exception is thrown if an edge being added is already a part of the graph.
-
class DuplicateNode : public Exception#
DuplicateNode exception is thrown if a node being added is already a part of the graph.
-
class Edge#
Subclassed by DGraph::Edge, Graph::Edge
Friends
- friend class BaseGraph
- friend class BaseGraph::DFSIterator
- friend class BaseGraph::BFSIterator
- friend class BaseGraph::DuplicateEdge
-
class EdgeInUse : public Exception#
EdgeInUse exception is thrown if an edge being added is already a part of another graph.
-
class EdgesIterator : public Iterator#
The edge iterator iterates over all the edges in the graph in no particular order.
Subclassed by DGraph::EdgesIterator, Graph::EdgesIterator
-
class EmptyEdge : public Exception#
EmptyEdge exception is thrown if an edge being added is null (0)
-
class Node#
Subclassed by DGraph::Node, Graph::Node
Friends
- friend class BaseGraph
- friend class BaseGraph::DFSIterator
- friend class BaseGraph::BFSIterator
-
class NodeInUse : public Exception#
NodeInUse exception is thrown if a node being added is already a part of another graph.
-
class NodesIterator : public Iterator#
The node iterator iterates over all the nodes in the graph in no particular order.
Subclassed by DGraph::NodesIterator, Graph::NodesIterator
-
class NonexistentEdge : public Exception#
NonexistentEdge exception is thrown if an edge being deleted is not a part of the graph.
-
class NonexistentNode : public Exception#
NonexistentNode exception is thrown if a node being deleted is not a part of the graph.