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