generic_graph_algorithms.h

00001 //===========================================================================
00002 // GoTools - SINTEF Geometry Tools
00003 //
00004 // GoTools module: Intersections, version 1.0
00005 //
00006 // Copyright (C) 2000-2007 SINTEF ICT, Applied Mathematics, Norway.
00007 //
00008 // This program is free software; you can redistribute it and/or          
00009 // modify it under the terms of the GNU General Public License            
00010 // as published by the Free Software Foundation version 2 of the License. 
00011 //
00012 // This program is distributed in the hope that it will be useful,        
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of         
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          
00015 // GNU General Public License for more details.                           
00016 //
00017 // You should have received a copy of the GNU General Public License      
00018 // along with this program; if not, write to the Free Software            
00019 // Foundation, Inc.,                                                      
00020 // 59 Temple Place - Suite 330,                                           
00021 // Boston, MA  02111-1307, USA.                                           
00022 //
00023 // Contact information: E-mail: tor.dokken@sintef.no                      
00024 // SINTEF ICT, Department of Applied Mathematics,                         
00025 // P.O. Box 124 Blindern,                                                 
00026 // 0314 Oslo, Norway.                                                     
00027 //
00028 // Other licenses are also available for this software, notably licenses
00029 // for:
00030 // - Building commercial software.                                        
00031 // - Building software whose source code you wish to keep private.        
00032 //===========================================================================
00033 #ifndef _GENERIC_GRAPH_ALGORITHMS_H
00034 #define _GENERIC_GRAPH_ALGORITHMS_H
00035 
00036 #include <vector>
00037 
00038 //===========================================================================
00039 //Paton's method for finding a fundamental set of cycles of an
00040 //undirected graph.  Connectivity information between nodes is
00041 //expressed by the functor 'connectedTo'.  NB: The outcome will be
00042 //_appended_ to the 'result' sequence, no clear() operator will be
00043 //called.
00044 template<class FunctorConnectedTo > // FunctorConnectedTo(x, y)
00045                                     // returns 'true' if the node
00046                                     // indexed 'x' shares an edge with
00047                                     // the node indexed 'y'.
00048 void get_fundamental_cycle_set(int num_nodes, // number of nodes in
00049                                               // set, they will be
00050                                               // indexed from 0
00051                                FunctorConnectedTo connectedTo, 
00052                                std::vector<std::vector<int> >& result); 
00053 //===========================================================================
00054 
00055 //===========================================================================
00056 //Paton's method for finding a fundamental set of cycles of an
00057 //undirected graph.  Connectivity information between nodes is
00058 //expressed by the 'table' sequence.  Entry 'i' in this table is a
00059 //list of indices of the nodes connected to node 'i'.  The sequence
00060 //'result' is NOT emptied before use!
00061 void get_fundamental_cycle_set(int num_nodes, 
00062                                const std::vector<std::vector<int> >& table,
00063                                std::vector<std::vector<int> >& result);
00064 //===========================================================================
00065 
00066 //===========================================================================
00067 // Determining whether there is a path between two nodes in a graph
00068 template<class FunctorConnectedTo> // Functor ConnectedTo(x,y) returns
00069                                    // 'true' if the node indexed 'x'
00070                                    // shares an edge with the node
00071                                    // indexed 'y'.
00072 bool is_path_connected(int node1_index, 
00073                        int node2_index, 
00074                        int num_nodes, 
00075                        FunctorConnectedTo connected_to); 
00076 //===========================================================================
00077 
00078 
00079 
00080 //===========================================================================
00081 //Will return all paths between branch-nodes, as well as all
00082 //remaining, closed cycles.  Branch nodes are defined as those nodes
00083 //incident with one, three or more edges.  (Nodes incident with 0
00084 //edges are isolated, nodes incident with two edges lie on an
00085 //"evident" path).  Closed cycles will be stored without duplication
00086 //of the first node at the end.
00087 template<class FunctorConnectedTo>
00088 void get_individual_paths(int num_nodes,
00089                           FunctorConnectedTo connectedTo,
00090                           std::vector<std::vector<int> >& paths,
00091                           std::vector<std::vector<int> >& cycles,
00092                           std::vector<int>& isolated_nodes);
00093 //===========================================================================
00094 
00095 
00096 
00097                                
00098 #include "generic_graph_algorithms_implementation.h"
00099 #endif // _GENERIC_GRAPH_ALGORITHMS_H
00100 

Generated on Fri Nov 23 12:24:32 2007 for GoTools Intersections Library by  doxygen 1.5.1