123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262 |
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
- <title>GTL - Graph Template Library: node.h Source File</title>
- <link href="doxygen.css" rel="stylesheet" type="text/css">
- </head>
- <body>
- <p class="links">
- <a href="../index.html">Home</a> |
- Documentation |
- <a href="../register.html">Download</a> |
- <a href="../platforms.html">Platforms</a> |
- <a href="../refer.html">Projects</a> |
- <a href="../lists.html">Mailing Lists</a> |
- <a href="../history.html">Version History</a>
- </p>
- <!-- Generated by Doxygen 1.5.3 -->
- <div class="tabs">
- <ul>
- <li><a href="index.html"><span>Main Page</span></a></li>
- <li><a href="classes.html"><span>Classes</span></a></li>
- <li class="current"><a href="files.html"><span>Files</span></a></li>
- <li><a href="pages.html"><span>Related Pages</span></a></li>
- </ul>
- </div>
- <h1>node.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">//==========================================================================</span>
- <a name="l00002"></a>00002 <span class="comment">//</span>
- <a name="l00003"></a>00003 <span class="comment">// node.h</span>
- <a name="l00004"></a>00004 <span class="comment">//</span>
- <a name="l00005"></a>00005 <span class="comment">//==========================================================================</span>
- <a name="l00006"></a>00006 <span class="comment">// $Id: node.h,v 1.20 2003/11/27 13:36:56 raitner Exp $</span>
- <a name="l00007"></a>00007
- <a name="l00008"></a>00008 <span class="preprocessor">#ifndef GTL_NODE_H</span>
- <a name="l00009"></a>00009 <span class="preprocessor"></span><span class="preprocessor">#define GTL_NODE_H</span>
- <a name="l00010"></a>00010 <span class="preprocessor"></span>
- <a name="l00011"></a>00011 <span class="preprocessor">#include <GTL/GTL.h></span>
- <a name="l00012"></a>00012 <span class="preprocessor">#include <GTL/edge.h></span>
- <a name="l00013"></a>00013
- <a name="l00014"></a>00014 <span class="preprocessor">#include <list></span>
- <a name="l00015"></a>00015
- <a name="l00016"></a>00016 __GTL_BEGIN_NAMESPACE
- <a name="l00017"></a>00017
- <a name="l00018"></a>00018 <span class="comment">//--------------------------------------------------------------------------</span>
- <a name="l00019"></a>00019 <span class="comment">// For MSVC 5.0 node.h has to be included before {node,edge}_data.h.</span>
- <a name="l00020"></a>00020 <span class="comment">// So we only declare node_data here</span>
- <a name="l00021"></a>00021 <span class="comment">//--------------------------------------------------------------------------</span>
- <a name="l00022"></a>00022
- <a name="l00023"></a>00023 <span class="keyword">class </span>node_data;
- <a name="l00024"></a>00024
- <a name="l00025"></a>00025 <span class="comment">//--------------------------------------------------------------------------</span>
- <a name="l00026"></a>00026 <span class="comment">// The first alternative is correct. The second one is a workaround</span>
- <a name="l00027"></a>00027 <span class="comment">// for compilers that don't support namespaces and use the SGI STL</span>
- <a name="l00028"></a>00028 <span class="comment">// (i.e. gcc/egcs)</span>
- <a name="l00029"></a>00029 <span class="comment">//--------------------------------------------------------------------------</span>
- <a name="l00030"></a>00030
- <a name="l00031"></a>00031 <span class="preprocessor">#ifdef __GTL_USE_NAMESPACES</span>
- <a name="l00032"></a>00032 <span class="preprocessor"></span>
- <a name="l00033"></a>00033 <span class="keyword">class </span><a class="code" href="a00020.html" title="A node in a graph.">node</a>;
- <a name="l00034"></a>00034 <span class="keyword">typedef</span> std::iterator<std::bidirectional_iterator_tag, edge> bi_iter_edge;
- <a name="l00035"></a>00035 <span class="keyword">typedef</span> std::iterator<std::bidirectional_iterator_tag, node> bi_iter_node;
- <a name="l00036"></a>00036
- <a name="l00037"></a>00037 <span class="preprocessor">#else</span>
- <a name="l00038"></a>00038 <span class="preprocessor"></span>
- <a name="l00039"></a>00039 <span class="keyword">class </span><a class="code" href="a00020.html" title="A node in a graph.">node</a>;
- <a name="l00040"></a>00040 <span class="keyword">typedef</span> bidirectional_iterator<edge,ptrdiff_t> bi_iter_edge;
- <a name="l00041"></a>00041 <span class="keyword">typedef</span> bidirectional_iterator<node,ptrdiff_t> bi_iter_node;
- <a name="l00042"></a>00042
- <a name="l00043"></a>00043 <span class="preprocessor">#endif // __GTL_USE_NAMESPACES</span>
- <a name="l00044"></a>00044 <span class="preprocessor"></span>
- <a name="l00045"></a>00045 <span class="comment">//--------------------------------------------------------------------------</span>
- <a name="l00046"></a>00046 <span class="comment">// nodes</span>
- <a name="l00047"></a>00047 <span class="comment">//--------------------------------------------------------------------------</span>
- <a name="l00048"></a>00048
- <a name="l00052"></a><a class="code" href="a00020.html">00052</a> <span class="keyword">class </span>GTL_EXTERN <a class="code" href="a00020.html" title="A node in a graph.">node</a>
- <a name="l00053"></a>00053 {
- <a name="l00054"></a>00054 <span class="keyword">public</span>:
- <a name="l00068"></a>00068 <a class="code" href="a00020.html" title="A node in a graph.">node</a>();
- <a name="l00069"></a>00069
- <a name="l00074"></a>00074 <span class="keywordtype">int</span> degree() <span class="keyword">const</span>;
- <a name="l00075"></a>00075
- <a name="l00079"></a>00079 <span class="keywordtype">int</span> outdeg() <span class="keyword">const</span>;
- <a name="l00080"></a>00080
- <a name="l00084"></a>00084 <span class="keywordtype">int</span> indeg() <span class="keyword">const</span>;
- <a name="l00085"></a>00085
- <a name="l00089"></a>00089 <span class="keywordtype">int</span> id() <span class="keyword">const</span>;
- <a name="l00090"></a>00090
- <a name="l00096"></a>00096 <span class="keyword">const</span> <a class="code" href="a00020.html" title="A node in a graph.">node</a>& opposite(<a class="code" href="a00010.html" title="An edge in a graph.">edge</a> e) <span class="keyword">const</span>;
- <a name="l00097"></a>00097
- <a name="l00101"></a>00101 list<node> opposites(<a class="code" href="a00010.html" title="An edge in a graph.">edge</a>) <span class="keyword">const</span>;
- <a name="l00102"></a>00102
- <a name="l00110"></a>00110 <span class="keywordtype">bool</span> is_hidden () <span class="keyword">const</span>;
- <a name="l00111"></a>00111
- <a name="l00118"></a>00118 <span class="keywordtype">int</span> excentricity() <span class="keyword">const</span>;
- <a name="l00119"></a>00119
- <a name="l00120"></a>00120 <span class="comment">//================================================== Iterator types</span>
- <a name="l00121"></a>00121
- <a name="l00125"></a>00125 <span class="keyword">typedef</span> list<edge>::const_iterator in_edges_iterator;
- <a name="l00129"></a>00129 <span class="keyword">typedef</span> list<edge>::const_iterator out_edges_iterator;
- <a name="l00130"></a>00130
- <a name="l00134"></a>00134 <span class="keyword">class </span>inout_edges_iterator;
- <a name="l00135"></a>00135
- <a name="l00139"></a>00139 <span class="keyword">class </span>adj_nodes_iterator;
- <a name="l00140"></a>00140
- <a name="l00144"></a>00144 <span class="keyword">class </span>adj_edges_iterator;
- <a name="l00145"></a>00145
- <a name="l00146"></a>00146 <span class="comment">//================================================== Iterators</span>
- <a name="l00147"></a>00147
- <a name="l00153"></a>00153 adj_nodes_iterator adj_nodes_begin() <span class="keyword">const</span>;
- <a name="l00154"></a>00154
- <a name="l00160"></a>00160 adj_nodes_iterator adj_nodes_end() <span class="keyword">const</span>;
- <a name="l00161"></a>00161
- <a name="l00167"></a>00167 adj_edges_iterator adj_edges_begin() <span class="keyword">const</span>;
- <a name="l00168"></a>00168
- <a name="l00174"></a>00174 adj_edges_iterator adj_edges_end() <span class="keyword">const</span>;
- <a name="l00175"></a>00175
- <a name="l00181"></a>00181 in_edges_iterator in_edges_begin() <span class="keyword">const</span>;
- <a name="l00182"></a>00182
- <a name="l00188"></a>00188 in_edges_iterator in_edges_end() <span class="keyword">const</span>;
- <a name="l00189"></a>00189
- <a name="l00195"></a>00195 out_edges_iterator out_edges_begin() <span class="keyword">const</span>;
- <a name="l00196"></a>00196
- <a name="l00202"></a>00202 out_edges_iterator out_edges_end() <span class="keyword">const</span>;
- <a name="l00203"></a>00203
- <a name="l00209"></a>00209 inout_edges_iterator inout_edges_begin() <span class="keyword">const</span>;
- <a name="l00210"></a>00210
- <a name="l00216"></a>00216 inout_edges_iterator inout_edges_end() <span class="keyword">const</span>;
- <a name="l00217"></a>00217
- <a name="l00218"></a>00218 <span class="comment">//================================================== Implementation</span>
- <a name="l00219"></a>00219
- <a name="l00220"></a>00220 <span class="keyword">private</span>:
- <a name="l00221"></a>00221 node_data *data;
- <a name="l00222"></a>00222
- <a name="l00223"></a>00223 <span class="keywordtype">bool</span> is_directed() <span class="keyword">const</span>;
- <a name="l00224"></a>00224 <span class="keywordtype">bool</span> is_undirected() <span class="keyword">const</span>;
- <a name="l00225"></a>00225
- <a name="l00226"></a>00226 <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="a00014.html" title="A directed or undirected graph.">graph</a>;
- <a name="l00227"></a>00227 <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="a00010.html" title="An edge in a graph.">edge</a>;
- <a name="l00228"></a>00228 <span class="keyword">friend</span> <span class="keyword">class </span>adj_edges_iterator;
- <a name="l00229"></a>00229
- <a name="l00230"></a>00230 GTL_EXTERN <span class="keyword">friend</span> <span class="keywordtype">bool</span> operator==(<a class="code" href="a00020.html" title="A node in a graph.">node</a>, <a class="code" href="a00020.html" title="A node in a graph.">node</a>);
- <a name="l00231"></a>00231 GTL_EXTERN <span class="keyword">friend</span> <span class="keywordtype">bool</span> operator!=(<a class="code" href="a00020.html" title="A node in a graph.">node</a>, <a class="code" href="a00020.html" title="A node in a graph.">node</a>);
- <a name="l00232"></a>00232 GTL_EXTERN <span class="keyword">friend</span> <span class="keywordtype">bool</span> operator<(<a class="code" href="a00020.html" title="A node in a graph.">node</a>, <a class="code" href="a00020.html" title="A node in a graph.">node</a>);
- <a name="l00233"></a>00233 GTL_EXTERN <span class="keyword">friend</span> ostream& operator<< (ostream& os, <span class="keyword">const</span> <a class="code" href="a00020.html" title="A node in a graph.">node</a>& n);
- <a name="l00234"></a>00234 };
- <a name="l00235"></a>00235
- <a name="l00236"></a>00236
- <a name="l00240"></a>00240 <span class="keyword">class </span>GTL_EXTERN <a class="code" href="a00020.html" title="A node in a graph.">node</a>::adj_edges_iterator : <span class="keyword">public</span> bi_iter_edge
- <a name="l00241"></a>00241 {
- <a name="l00242"></a>00242 <span class="keyword">public</span>:
- <a name="l00243"></a>00243
- <a name="l00244"></a>00244 <span class="comment">// constructor</span>
- <a name="l00245"></a>00245 adj_edges_iterator();
- <a name="l00246"></a>00246 adj_edges_iterator(<a class="code" href="a00020.html" title="A node in a graph.">node</a>, <span class="keywordtype">bool</span>);
- <a name="l00247"></a>00247
- <a name="l00248"></a>00248 <span class="comment">// comparibility</span>
- <a name="l00249"></a>00249 <span class="keywordtype">bool</span> operator==(<span class="keyword">const</span> adj_edges_iterator&) <span class="keyword">const</span>;
- <a name="l00250"></a>00250 <span class="keywordtype">bool</span> operator!=(<span class="keyword">const</span> adj_edges_iterator&) <span class="keyword">const</span>;
- <a name="l00251"></a>00251
- <a name="l00252"></a>00252 <span class="comment">// operators</span>
- <a name="l00253"></a>00253 adj_edges_iterator &operator++();
- <a name="l00254"></a>00254 adj_edges_iterator operator++(<span class="keywordtype">int</span>);
- <a name="l00255"></a>00255 adj_edges_iterator &operator--();
- <a name="l00256"></a>00256 adj_edges_iterator operator--(<span class="keywordtype">int</span>);
- <a name="l00257"></a>00257
- <a name="l00258"></a>00258 <span class="comment">// dereferencing</span>
- <a name="l00259"></a>00259 <span class="keyword">const</span> <a class="code" href="a00010.html" title="An edge in a graph.">edge</a>& operator*() <span class="keyword">const</span>;
- <a name="l00260"></a>00260 <span class="keyword">const</span> <a class="code" href="a00010.html" title="An edge in a graph.">edge</a>* operator->() <span class="keyword">const</span>;
- <a name="l00261"></a>00261
- <a name="l00262"></a>00262 <span class="keyword">private</span>:
- <a name="l00263"></a>00263 in_edges_iterator akt_edge[2], last_edge[2], begin_edge[2];
- <a name="l00264"></a>00264 <span class="keywordtype">int</span> inout; <span class="comment">// in=0, out=1</span>
- <a name="l00265"></a>00265 <span class="keywordtype">bool</span> directed; <span class="comment">// graph directed ??</span>
- <a name="l00266"></a>00266 };
- <a name="l00267"></a>00267
- <a name="l00271"></a>00271 <span class="keyword">class </span>GTL_EXTERN <a class="code" href="a00020.html" title="A node in a graph.">node</a>::inout_edges_iterator : <span class="keyword">public</span> bi_iter_edge
- <a name="l00272"></a>00272 {
- <a name="l00273"></a>00273 <span class="keyword">public</span>:
- <a name="l00274"></a>00274
- <a name="l00275"></a>00275 <span class="comment">// constructor</span>
- <a name="l00276"></a>00276 inout_edges_iterator();
- <a name="l00277"></a>00277 inout_edges_iterator(<a class="code" href="a00020.html" title="A node in a graph.">node</a> n, <span class="keywordtype">bool</span> start);
- <a name="l00278"></a>00278
- <a name="l00279"></a>00279 <span class="comment">// comparibility</span>
- <a name="l00280"></a>00280 <span class="keywordtype">bool</span> operator==(<span class="keyword">const</span> inout_edges_iterator&) <span class="keyword">const</span>;
- <a name="l00281"></a>00281 <span class="keywordtype">bool</span> operator!=(<span class="keyword">const</span> inout_edges_iterator&) <span class="keyword">const</span>;
- <a name="l00282"></a>00282
- <a name="l00283"></a>00283 <span class="comment">// operators</span>
- <a name="l00284"></a>00284 inout_edges_iterator &operator++();
- <a name="l00285"></a>00285 inout_edges_iterator operator++(<span class="keywordtype">int</span>);
- <a name="l00286"></a>00286 inout_edges_iterator &operator--();
- <a name="l00287"></a>00287 inout_edges_iterator operator--(<span class="keywordtype">int</span>);
- <a name="l00288"></a>00288
- <a name="l00289"></a>00289 <span class="comment">// dereferencing</span>
- <a name="l00290"></a>00290 <span class="keyword">const</span> <a class="code" href="a00010.html" title="An edge in a graph.">edge</a>& operator*() <span class="keyword">const</span>;
- <a name="l00291"></a>00291 <span class="keyword">const</span> <a class="code" href="a00010.html" title="An edge in a graph.">edge</a>* operator->() <span class="keyword">const</span>;
- <a name="l00292"></a>00292
- <a name="l00293"></a>00293 <span class="keyword">private</span>:
- <a name="l00294"></a>00294 in_edges_iterator akt_edge[2], last_edge, begin_edge;
- <a name="l00295"></a>00295 <span class="keywordtype">int</span> inout; <span class="comment">// in=0, out=1</span>
- <a name="l00296"></a>00296 };
- <a name="l00297"></a>00297
- <a name="l00301"></a>00301 <span class="keyword">class </span>GTL_EXTERN <a class="code" href="a00020.html" title="A node in a graph.">node</a>::adj_nodes_iterator : <span class="keyword">public</span> bi_iter_node
- <a name="l00302"></a>00302 {
- <a name="l00303"></a>00303 <span class="keyword">public</span>:
- <a name="l00304"></a>00304
- <a name="l00305"></a>00305 <span class="comment">// constructor</span>
- <a name="l00306"></a>00306 adj_nodes_iterator();
- <a name="l00307"></a>00307 adj_nodes_iterator(<span class="keyword">const</span> <a class="code" href="a00020.html" title="A node in a graph.">node</a>&, <span class="keywordtype">bool</span>);
- <a name="l00308"></a>00308
- <a name="l00309"></a>00309 <span class="comment">// comparibility</span>
- <a name="l00310"></a>00310 <span class="keywordtype">bool</span> operator==(<span class="keyword">const</span> adj_nodes_iterator&) <span class="keyword">const</span>;
- <a name="l00311"></a>00311 <span class="keywordtype">bool</span> operator!=(<span class="keyword">const</span> adj_nodes_iterator&) <span class="keyword">const</span>;
- <a name="l00312"></a>00312
- <a name="l00313"></a>00313 <span class="comment">// operators</span>
- <a name="l00314"></a>00314 adj_nodes_iterator &operator++();
- <a name="l00315"></a>00315 adj_nodes_iterator operator++(<span class="keywordtype">int</span>);
- <a name="l00316"></a>00316 adj_nodes_iterator &operator--();
- <a name="l00317"></a>00317 adj_nodes_iterator operator--(<span class="keywordtype">int</span>);
- <a name="l00318"></a>00318
- <a name="l00319"></a>00319 <span class="comment">// dereferencing</span>
- <a name="l00320"></a>00320 <span class="keyword">const</span> <a class="code" href="a00020.html" title="A node in a graph.">node</a>& operator*() <span class="keyword">const</span>;
- <a name="l00321"></a>00321 <span class="keyword">const</span> <a class="code" href="a00020.html" title="A node in a graph.">node</a>* operator->() <span class="keyword">const</span>;
- <a name="l00322"></a>00322
- <a name="l00323"></a>00323 <span class="keyword">private</span>:
- <a name="l00324"></a>00324 adj_edges_iterator akt_edge;
- <a name="l00325"></a>00325 <a class="code" href="a00020.html" title="A node in a graph.">node</a> int_node;
- <a name="l00326"></a>00326 };
- <a name="l00327"></a>00327
- <a name="l00328"></a>00328
- <a name="l00329"></a>00329 __GTL_END_NAMESPACE
- <a name="l00330"></a>00330
- <a name="l00331"></a>00331 <span class="comment">//--------------------------------------------------------------------------</span>
- <a name="l00332"></a>00332 <span class="comment">// Iteration</span>
- <a name="l00333"></a>00333 <span class="comment">//--------------------------------------------------------------------------</span>
- <a name="l00334"></a>00334
- <a name="l00335"></a>00335 <span class="comment">// #define forall_adj_nodes(v,w) GTL_FORALL(v,w,node::adj_nodes_iterator,adj_nodes_)</span>
- <a name="l00336"></a>00336 <span class="preprocessor">#define forall_out_edges(e,v) GTL_FORALL(e,v,node::out_edges_iterator,out_edges_)</span>
- <a name="l00337"></a>00337 <span class="preprocessor"></span><span class="preprocessor">#define forall_in_edges(e,v) GTL_FORALL(e,v,node::in_edges_iterator,in_edges_)</span>
- <a name="l00338"></a>00338 <span class="preprocessor"></span><span class="preprocessor">#define forall_inout_edges(e,v) GTL_FORALL(e,v,node::inout_edges_iterator,inout_edges_)</span>
- <a name="l00339"></a>00339 <span class="preprocessor"></span><span class="preprocessor">#define forall_adj_edges(e,v) GTL_FORALL(e,v,node::adj_edges_iterator,adj_edges_)</span>
- <a name="l00340"></a>00340 <span class="preprocessor"></span>
- <a name="l00341"></a>00341 <span class="preprocessor">#endif // GTL_NODE_H</span>
- <a name="l00342"></a>00342 <span class="preprocessor"></span>
- <a name="l00343"></a>00343 <span class="comment">//--------------------------------------------------------------------------</span>
- <a name="l00344"></a>00344 <span class="comment">// end of file</span>
- <a name="l00345"></a>00345 <span class="comment">//--------------------------------------------------------------------------</span>
- </pre></div> <p class="links">
- <a href="http://www.uni-passau.de/">University of Passau</a>
- -
- <a href="http://www.fmi.uni-passau.de/">FMI</a>
- -
- <a href="http://www.fmi.uni-passau.de/fmi/lehrstuehle/brandenburg/">Theoretical
- Computer Science</a>
- </p>
- <div class="copyright">
- Design © 2002, 2003 <a href="mailto:raitner@fmi.uni-passau.de">Marcus Raitner</a>, University of Passau
- </div>
- </body>
- </html>
|