@node The Full Feature Graph Class
@section The Full Feature Graph Class
@cindex Full Feature Graph Class
This section describes what an imaginary full feature graph class knows.
The set of features provided by a real graph implementation is typically
a subset of the features below.
On the other hand, each graph algorithm requires the underlying graph
structure to provide a certain (typically small) set of features in order
to be able to run.
@subsection Declaration
@deftp {Class} {class Graph}
@code{Graph} is the imaginary @emph{full feature graph class}.
@code{G} denotes the instance of this class in the exaples below.
@c Each node and edge has a user defined data sturcure
@c @var{N} and @var{E} statically attached to it.
@end deftp
@subsection Types
@deftp {Type} Graph::NodeType
@deftpx {Type} Graph::EdgeType
The type of the data stored statically for each node and edge.
@end deftp
@anchor{Graph-NodeIterator}
@deftp {Type} Graph::NodeIt
@deftpx {Type} Graph::NodeIterator
These types points a node uniquely. The difference between the
@code{NodeIt} and the @code{NodeIterator} is that @code{NodeIt}
requires the graph structure itself for most of the operations.
For examples using iterators you can go through all nodes as follows.
@quotation
@verbatim
Graph G;
int nodenum=0;
for(Graph::NodeIterator n(G);n.valid();++n) ++nodenum;
@end verbatim
@end quotation
Using @code{NodeIt} the last line looks like this.
@quotation
@verbatim
for(Graph::NodeIt n(G);n.valid();n=G.next(n)) ++nodenum;
@end verbatim
@end quotation
or
@quotation
@verbatim
MyGraph::NodeIt n;
for(G.getFirst(n);G.valid(n);G.goNext(n)) ++nodenum;
@end verbatim
@end quotation
@end deftp
@deftp {Type} Graph::EdgeIt
@deftpx {Type} Graph::InEdgeIt
@deftpx {Type} Graph::OutEdgeIt
@deftpx {Type} Graph::BiEdgeIt
@deftpx {Type} Graph::SymEdgeIt
Each of these types points an edge uniquely. The difference between the
@code{EdgeIt} and the
@c @mref{Graph-NodeIterator,@code{EdgeIterator}}
@mref{Graph-NodeIterator , EdgeIterator}
series is that
@code{EdgeIt} requires the graph structure itself for most of the
operations.
@end deftp
@anchor{Graph-EdgeIterator}
@deftp {Type} Graph::EdgeIterator
@deftpx {Type} Graph::InEdgeIterator
@deftpx {Type} Graph::OutEdgeIterator
@deftpx {Type} Graph::BiEdgeIterator
@deftpx {Type} Graph::SymEdgeIterator
@deftpx {Type} Graph::EachEdgeIterator
Each of these types points an edge uniquely. The difference between the
@code{EdgeIt} and the @code{EdgeIterator} series is that
@code{EdgeIt} requires the graph structure itself for most of the
operations.
For the @code{EdgeIterator} types you can use operator @code{++}
(both the prefix and the posfix one) to obtain the next edge.
@end deftp
@deftp {Type} Graph::NodeMap
@deftpx {Type} Graph::EdgeMap
There are the default property maps for the edges and the nodes.
@end deftp
@subsection Member Functions
@subsubsection Constructors
@deftypefun { } Graph::Graph ()
The default constructor.
@end deftypefun
@c @deftypefun { } Graph::Graph (Graph@tie{}&)
@deftypefun { } Graph::Graph (Graph &)
The copy constructor. Not yet implemented.
@end deftypefun
@subsubsection Graph Maintenence Operations
@deftypefun NodeIterator Graph::addNode ()
Adds a new node to the graph and returns a @code{NodeIterator} pointing to it.
@end deftypefun
@deftypefun EdgeIterator Graph::addEdge (@w{const @mref{Graph-NodeIterator,NodeIterator} @var{from}}, @w{const @mref{Graph-NodeIterator,NodeIterator} @var{to}})
Adds a new edge with tail @var{from} and head @var{to} to the graph
and returns an @code{EdgeIterator} pointing to it.
@end deftypefun
@deftypefun void Graph::delete (@w{const @mref{Graph-NodeIterator,NodeIterator} @var{n}})
Deletes the node @var{n}. It also deletes the adjacent edges.
@end deftypefun
@deftypefun void Graph::delete (@w{const @mref{Graph-EdgeIterator,EdgeIterator} @var{e}})
Deletes the edge @var{n}.
@end deftypefun
@deftypefun void Graph::clean ()
Deletes all edges and nodes from the graph.
@end deftypefun
@deftypefun int Graph::nodeNum ()
Returns the number of the nodes in the graph.
@end deftypefun
@subsubsection NodeIt Operations
@deftypefun NodeIt Graph::getFirst (NodeIt &@var{n})
@deftypefunx NodeIt Graph::next (const NodeIt @var{n})
@deftypefunx {NodeIt &} Graph::goNext (NodeIt &@var{n})
The nodes in the graph forms a list. @code{GetFirst(n)} sets @var{n} to
be the first node. @code{next(n)} gives back the subsequent
node. @code{Next(n)} is equivalent to @code{n=Next(n)}, though it
might be faster. ??? What should be the return value ???
@end deftypefun
@deftypefun bool Graph::valid (NodeIt &@var{e})
@deftypefunx bool NodeIt::valid ()
These functions check if and NodeIt is valid or not.
??? Which one should be implemented ???
@end deftypefun
@subsubsection EdgeIt Operations
@deftypefun EachEdgeIt Graph::getFirst (const EachEdgeIt & @var{e})
@deftypefunx EachEdgeIt Graph::next (const EachEdgeIt @var{n})
@deftypefunx {EachEdgeIt &} Graph::goNext (EachEdgeIt &@var{n})
With these functions you can go though all the edges of the graph.
??? What should be the return value ???
@end deftypefun
@deftypefun InEdgeIt Graph::getFirst (const InEdgeIt & @var{e}, const NodeIt @var{n})
@deftypefunx OutEdgeIt Graph::getFirst (const OutEdgeIt & @var{e}, const NodeIt @var{n})
@deftypefunx SymEdgeIt Graph::getFirst (const SymEdgeIt & @var{e}, const NodeIt @var{n})
The edges leaving from, arriving at or adjacent with a node forms a
list. These functions give back the first elements of these
lists. The exact behavior depends on the type of @var{e}.
If @var{e} is an @code{InEdgeIt} or an @code{OutEdgeIt} then
@code{getFirst} sets @var{e} to be the first incoming or outgoing edge
of the node @var{n}, respectively.
If @var{e} is a @code{SymEdgeIt} then
@code{getFirst} sets @var{e} to be the first incoming if there exists one
otherwise the first outgoing edge.
If there are no such edges, @var{e} will be invalid.
@end deftypefun
@deftypefun InEdgeIt Graph::next (const InEdgeIt @var{e})
@deftypefunx OutEdgeIt Graph::next (const OutEdgeIt @var{e})
@deftypefunx SymEdgeIt Graph::next (const SymEdgeIt @var{e})
These functions give back the edge that follows @var{e}
@end deftypefun
@deftypefun {InEdgeIt &} Graph::goNext (InEdgeIt &@var{e})
@deftypefunx {OutEdgeIt &} Graph::goNext (OutEdgeIt &@var{e})
@deftypefunx {SymEdgeIt &} Graph::goNext (SymEdgeIt &@var{e})
@code{G.goNext(e)} is equivalent to @code{e=G.next(e)}, though it
might be faster.
??? What should be the return value ???
@end deftypefun
@deftypefun bool Graph::valid (EdgeIt &@var{e})
@deftypefunx bool EdgeIt::valid ()
These functions check if and EdgeIt is valid or not.
??? Which one should be implemented ???
@end deftypefun
@deftypefun NodeIt Graph::tail (const EdgeIt @var{e})
@deftypefunx NodeIt Graph::head (const EdgeIt @var{e})
@deftypefunx NodeIt Graph::aNode (const InEdgeIt @var{e})
@deftypefunx NodeIt Graph::aNode (const OutEdgeIt @var{e})
@deftypefunx NodeIt Graph::aNode (const SymEdgeIt @var{e})
@deftypefunx NodeIt Graph::bNode (const InEdgeIt @var{e})
@deftypefunx NodeIt Graph::bNode (const OutEdgeIt @var{e})
@deftypefunx NodeIt Graph::bNode (const SymEdgeIt @var{e})
There queries give back the two endpoints of the edge @var{e}. For a
directed edge @var{e}, @code{tail(e)} and @code{head(e)} is its tail and
its head, respectively. For an undirected @var{e}, they are two
endpoints, but you should not rely on which end is which.
@code{aNode(e)} is the node which @var{e} is bounded to, i.e. it is
equal to @code{tail(e)} if @var{e} is an @code{OutEdgeIt} and
@code{head(e)} if @var{e} is an @code{InEdgeIt}. If @var{e} is a
@code{SymEdgeIt} and it or its first preceding edge was created by
@code{getFirst(e,n)}, then @code{aNode(e)} is equal to @var{n}.
@code{bNode(e)} is the other end of the edge.
???It is implemented in an other way now. (Member function <-> Graph global)???
@end deftypefun
@c @deftypevar int from
@c the tail of the created edge.
@c @end deftypevar