doc/flf-graph.texi
author alpar
Fri, 12 Mar 2004 15:42:51 +0000
changeset 177 924f9555711d
parent 26 383e95b237c4
child 203 fc4699a76a6f
permissions -rw-r--r--
Marci's changes accepted.
alpar@18
     1
@node The Full Feature Graph Class
alpar@18
     2
@section The Full Feature Graph Class
alpar@18
     3
@cindex Full Feature Graph Class
alpar@18
     4
alpar@18
     5
This section describes what an imaginary full feature graph class knows.
alpar@18
     6
The set of features provided by a real graph implementation is typically
alpar@18
     7
a subset of the features below.
alpar@18
     8
alpar@18
     9
On the other hand, each graph algorithm requires the underlying graph
alpar@18
    10
structure to provide a certain (typically small) set of features in order
alpar@18
    11
to be able to run.
alpar@18
    12
alpar@18
    13
@subsection Declaration
alpar@18
    14
alpar@18
    15
@deftp {Class} {class Graph}
alpar@18
    16
@code{Graph} is the imaginary @emph{full feature graph class}.
alpar@18
    17
@code{G} denotes the instance of this class in the exaples below.
alpar@18
    18
@c Each node and edge has a user defined data sturcure
alpar@18
    19
@c @var{N} and @var{E} statically attached to it.
alpar@18
    20
@end deftp
alpar@18
    21
alpar@18
    22
@subsection Types
alpar@18
    23
alpar@18
    24
@deftp {Type} Graph::NodeType
alpar@18
    25
@deftpx {Type} Graph::EdgeType
alpar@18
    26
The type of the data stored statically for each node and edge.
alpar@18
    27
@end deftp
alpar@18
    28
alpar@18
    29
@anchor{Graph-NodeIterator}
alpar@70
    30
@deftp {Type} Graph::NodeIt
alpar@18
    31
@deftpx {Type} Graph::NodeIterator
alpar@18
    32
These types points a node uniquely. The difference between the
alpar@70
    33
@code{NodeIt} and the @code{NodeIterator} is that @code{NodeIt}
alpar@18
    34
requires the graph structure itself for most of the operations.
alpar@18
    35
For examples using iterators you can go through all nodes as follows.
alpar@18
    36
@quotation
alpar@18
    37
@verbatim
alpar@18
    38
Graph G;
alpar@18
    39
int nodenum=0;
alpar@70
    40
for(Graph::NodeIterator n(G);n.valid();++n) ++nodenum;
alpar@18
    41
@end verbatim
alpar@18
    42
@end quotation
alpar@70
    43
Using @code{NodeIt} the last line looks like this.
alpar@18
    44
@quotation
alpar@18
    45
@verbatim
alpar@70
    46
for(Graph::NodeIt n(G);n.valid();n=G.next(n)) ++nodenum;
alpar@18
    47
@end verbatim
alpar@18
    48
@end quotation
alpar@18
    49
or
alpar@18
    50
@quotation
alpar@18
    51
@verbatim
alpar@70
    52
MyGraph::NodeIt n;
alpar@70
    53
for(G.getFirst(n);G.valid(n);G.goNext(n)) ++nodenum;
alpar@18
    54
@end verbatim
alpar@18
    55
@end quotation
alpar@18
    56
@end deftp
alpar@18
    57
alpar@70
    58
@deftp {Type} Graph::EdgeIt
alpar@70
    59
@deftpx {Type} Graph::InEdgeIt
alpar@70
    60
@deftpx {Type} Graph::OutEdgeIt
alpar@70
    61
@deftpx {Type} Graph::BiEdgeIt
alpar@70
    62
@deftpx {Type} Graph::SymEdgeIt
alpar@18
    63
Each of these types points an edge uniquely. The difference between the
alpar@70
    64
@code{EdgeIt} and the
alpar@18
    65
@c @mref{Graph-NodeIterator,@code{EdgeIterator}}
alpar@18
    66
@mref{Graph-NodeIterator , EdgeIterator}
alpar@18
    67
series is that
alpar@70
    68
@code{EdgeIt} requires the graph structure itself for most of the
alpar@18
    69
operations.
alpar@18
    70
@end deftp
alpar@18
    71
alpar@18
    72
@anchor{Graph-EdgeIterator}
alpar@18
    73
@deftp {Type} Graph::EdgeIterator
alpar@18
    74
@deftpx {Type} Graph::InEdgeIterator
alpar@18
    75
@deftpx {Type} Graph::OutEdgeIterator
alpar@18
    76
@deftpx {Type} Graph::BiEdgeIterator
alpar@18
    77
@deftpx {Type} Graph::SymEdgeIterator
alpar@70
    78
@deftpx {Type} Graph::EachEdgeIterator
alpar@18
    79
Each of these types points an edge uniquely. The difference between the
alpar@70
    80
@code{EdgeIt} and the @code{EdgeIterator} series is that
alpar@70
    81
@code{EdgeIt} requires the graph structure itself for most of the
alpar@18
    82
operations. 
alpar@18
    83
alpar@18
    84
For the @code{EdgeIterator} types you can use operator @code{++}
alpar@18
    85
(both the prefix and the posfix one) to obtain the next edge.
alpar@18
    86
@end deftp
alpar@18
    87
alpar@18
    88
@deftp {Type} Graph::NodeMap
alpar@18
    89
@deftpx {Type} Graph::EdgeMap
alpar@18
    90
There are the default property maps for the edges and the nodes.
alpar@18
    91
@end deftp
alpar@18
    92
alpar@18
    93
alpar@18
    94
@subsection Member Functions
alpar@18
    95
alpar@18
    96
@subsubsection Constructors
alpar@18
    97
alpar@18
    98
alpar@18
    99
@deftypefun { } Graph::Graph ()
alpar@18
   100
The default constructor.
alpar@18
   101
@end deftypefun
alpar@18
   102
alpar@26
   103
@c @deftypefun { } Graph::Graph (Graph@tie{}&)
alpar@26
   104
@deftypefun { } Graph::Graph (Graph &)
alpar@18
   105
The copy constructor. Not yet implemented.
alpar@18
   106
@end deftypefun
alpar@18
   107
alpar@18
   108
@subsubsection Graph Maintenence Operations
alpar@18
   109
alpar@70
   110
@deftypefun NodeIterator Graph::addNode ()
alpar@18
   111
Adds a new node to the graph and returns a @code{NodeIterator} pointing to it.
alpar@18
   112
@end deftypefun
alpar@18
   113
alpar@70
   114
@deftypefun EdgeIterator Graph::addEdge (@w{const @mref{Graph-NodeIterator,NodeIterator} @var{from}}, @w{const @mref{Graph-NodeIterator,NodeIterator} @var{to}})
alpar@18
   115
Adds a new edge with tail @var{from} and head @var{to} to the graph
alpar@18
   116
and returns an @code{EdgeIterator} pointing to it.
alpar@18
   117
@end deftypefun
alpar@18
   118
alpar@70
   119
@deftypefun void Graph::delete (@w{const @mref{Graph-NodeIterator,NodeIterator} @var{n}})
alpar@18
   120
Deletes the node @var{n}. It also deletes the adjacent edges.
alpar@18
   121
@end deftypefun
alpar@18
   122
alpar@70
   123
@deftypefun void Graph::delete (@w{const @mref{Graph-EdgeIterator,EdgeIterator} @var{e}})
alpar@18
   124
Deletes the edge @var{n}.
alpar@18
   125
@end deftypefun
alpar@18
   126
alpar@70
   127
@deftypefun void Graph::clean ()
alpar@18
   128
Deletes all edges and nodes from the graph.
alpar@18
   129
@end deftypefun
alpar@18
   130
alpar@70
   131
@deftypefun int Graph::nodeNum ()
alpar@18
   132
Returns the number of the nodes in the graph.
alpar@18
   133
@end deftypefun
alpar@18
   134
alpar@70
   135
@subsubsection NodeIt Operations
alpar@18
   136
alpar@70
   137
@deftypefun NodeIt Graph::getFirst (NodeIt &@var{n})
alpar@70
   138
@deftypefunx NodeIt Graph::next (const NodeIt @var{n})
alpar@70
   139
@deftypefunx {NodeIt &} Graph::goNext (NodeIt &@var{n})
alpar@18
   140
The nodes in the graph forms a list. @code{GetFirst(n)} sets @var{n} to
alpar@70
   141
be the first node. @code{next(n)} gives back the subsequent
alpar@18
   142
node. @code{Next(n)} is equivalent to @code{n=Next(n)}, though it
alpar@18
   143
might be faster.  ??? What should be the return value ???
alpar@18
   144
@end deftypefun
alpar@18
   145
alpar@70
   146
@deftypefun bool Graph::valid (NodeIt &@var{e})
alpar@70
   147
@deftypefunx bool NodeIt::valid ()
alpar@70
   148
These functions check if and NodeIt is valid or not.
alpar@18
   149
??? Which one should be implemented ???
alpar@18
   150
@end deftypefun
alpar@18
   151
alpar@70
   152
@subsubsection EdgeIt Operations
alpar@18
   153
alpar@70
   154
@deftypefun EachEdgeIt Graph::getFirst (const EachEdgeIt & @var{e})
alpar@70
   155
@deftypefunx EachEdgeIt Graph::next (const EachEdgeIt @var{n})
alpar@70
   156
@deftypefunx {EachEdgeIt &} Graph::goNext (EachEdgeIt &@var{n})
alpar@18
   157
With these functions you can go though all the edges of the graph.
alpar@18
   158
??? What should be the return value ???
alpar@18
   159
@end deftypefun
alpar@18
   160
alpar@70
   161
@deftypefun InEdgeIt Graph::getFirst (const InEdgeIt & @var{e}, const NodeIt @var{n})
alpar@70
   162
@deftypefunx OutEdgeIt Graph::getFirst (const OutEdgeIt & @var{e}, const NodeIt @var{n})
alpar@70
   163
@deftypefunx SymEdgeIt Graph::getFirst (const SymEdgeIt & @var{e}, const NodeIt @var{n})
alpar@18
   164
The edges leaving from, arriving at or adjacent with a node forms a
alpar@18
   165
list.  These functions give back the first elements of these
alpar@18
   166
lists. The exact behavior depends on the type of @var{e}.
alpar@18
   167
alpar@70
   168
If @var{e} is an @code{InEdgeIt} or an @code{OutEdgeIt} then
alpar@70
   169
@code{getFirst} sets @var{e} to be the first incoming or outgoing edge
alpar@18
   170
of the node @var{n}, respectively.
alpar@18
   171
alpar@70
   172
If @var{e} is a @code{SymEdgeIt} then
alpar@70
   173
@code{getFirst} sets @var{e} to be the first incoming if there exists one
alpar@18
   174
otherwise the first outgoing edge.
alpar@18
   175
alpar@18
   176
If there are no such edges, @var{e} will be invalid.
alpar@18
   177
alpar@18
   178
@end deftypefun
alpar@18
   179
alpar@70
   180
@deftypefun InEdgeIt Graph::next (const InEdgeIt @var{e})
alpar@70
   181
@deftypefunx OutEdgeIt Graph::next (const OutEdgeIt @var{e})
alpar@70
   182
@deftypefunx SymEdgeIt Graph::next (const SymEdgeIt @var{e})
alpar@18
   183
These functions give back the edge that follows @var{e}
alpar@18
   184
@end deftypefun
alpar@18
   185
alpar@70
   186
@deftypefun {InEdgeIt &} Graph::goNext (InEdgeIt &@var{e})
alpar@70
   187
@deftypefunx {OutEdgeIt &} Graph::goNext (OutEdgeIt &@var{e})
alpar@70
   188
@deftypefunx {SymEdgeIt &} Graph::goNext (SymEdgeIt &@var{e})
alpar@70
   189
@code{G.goNext(e)} is equivalent to @code{e=G.next(e)}, though it
alpar@18
   190
might be faster.
alpar@18
   191
??? What should be the return value ???
alpar@18
   192
@end deftypefun
alpar@18
   193
alpar@70
   194
@deftypefun bool Graph::valid (EdgeIt &@var{e})
alpar@70
   195
@deftypefunx bool EdgeIt::valid ()
alpar@70
   196
These functions check if and EdgeIt is valid or not.
alpar@18
   197
??? Which one should be implemented ???
alpar@18
   198
@end deftypefun
alpar@18
   199
alpar@70
   200
@deftypefun NodeIt Graph::tail (const EdgeIt @var{e})
alpar@70
   201
@deftypefunx NodeIt Graph::head (const EdgeIt @var{e})
alpar@70
   202
@deftypefunx NodeIt Graph::aNode (const InEdgeIt @var{e})
alpar@70
   203
@deftypefunx NodeIt Graph::aNode (const OutEdgeIt @var{e})
alpar@70
   204
@deftypefunx NodeIt Graph::aNode (const SymEdgeIt @var{e})
alpar@70
   205
@deftypefunx NodeIt Graph::bNode (const InEdgeIt @var{e})
alpar@70
   206
@deftypefunx NodeIt Graph::bNode (const OutEdgeIt @var{e})
alpar@70
   207
@deftypefunx NodeIt Graph::bNode (const SymEdgeIt @var{e})
alpar@18
   208
There queries give back the two endpoints of the edge @var{e}.  For a
alpar@70
   209
directed edge @var{e}, @code{tail(e)} and @code{head(e)} is its tail and
alpar@18
   210
its head, respectively. For an undirected @var{e}, they are two
alpar@18
   211
endpoints, but you should not rely on which end is which.
alpar@18
   212
alpar@70
   213
@code{aNode(e)} is the node which @var{e} is bounded to, i.e. it is
alpar@70
   214
equal to @code{tail(e)} if @var{e} is an @code{OutEdgeIt} and
alpar@70
   215
@code{head(e)} if @var{e} is an @code{InEdgeIt}. If @var{e} is a
alpar@70
   216
@code{SymEdgeIt} and it or its first preceding edge was created by
alpar@70
   217
@code{getFirst(e,n)}, then @code{aNode(e)} is equal to @var{n}.
alpar@18
   218
alpar@70
   219
@code{bNode(e)} is the other end of the edge.
alpar@18
   220
alpar@70
   221
???It is implemented in an other way now. (Member function <-> Graph global)???
alpar@18
   222
@end deftypefun
alpar@18
   223
alpar@18
   224
alpar@18
   225
alpar@18
   226
@c @deftypevar int from
alpar@18
   227
@c  the tail of the created edge.
alpar@18
   228
@c @end deftypevar