All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BidirectionalGraph.h
Go to the documentation of this file.
1 /* Copyright (C) 2001-2009 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file BidirectionalGraph.h
22 
23  \brief This is a implementation of a Bidirectional Graph.
24  By convention a bidirectional graph provides access to
25  out-and in edges.
26 */
27 
28 #ifndef __TERRALIB_GRAPH_INTERNAL_BIDIRECTIONALGRAPH_H
29 #define __TERRALIB_GRAPH_INTERNAL_BIDIRECTIONALGRAPH_H
30 
31 // Terralib Includes
32 #include "../Config.h"
33 #include "Graph.h"
34 
35 // STL Includes
36 #include <vector>
37 
38 namespace te
39 {
40  namespace graph
41  {
42  //forward declarations
43  class AbstractCachePolicy;
44  class AbstractGraphLoaderStrategy;
45 
46  /*!
47  \class BidirectionalGraph
48 
49  \brief This is a implementation of a Bidirectional Graph.
50  By convention a bidirectional graph provides access to
51  out-and in edges.
52 
53  \sa AbstractGraph, GraphData, GraphCache
54  */
55 
57  {
58  public:
59 
60  /*! \brief constructor. */
62 
63  /*!
64  \brief Constructor
65 
66  \param cp A pointer to a cache policy implementation
67 
68  \param ls A pointer to a loader strategy implementation
69 
70  */
72 
73  /*! \brief Virtual destructor. */
75 
76  /** @name Vertex Access Methods
77  * Method used to access vertex elements from a graph.
78  */
79  //@{
80 
81  /*!
82  \brief The neighborhood of a vertex v is an induced subgraph of the graph, formed by all vertices adjacent to v.
83 
84  \param id The attribute used to identify the vertex element
85 
86  \return A vector with vertex elements.
87  */
88  virtual std::vector<te::graph::Vertex*> getVertexNeighborhood(int id);
89 
90  /*!
91  \brief This function indicates if a desired element is a isolated vertex.
92 
93  \param id The attribute used to identify the vertex element
94 
95  \param flag Flag used to indicating if the element is a isolated vertex.
96 
97  \return True if the vertex element was found and false in other case
98  */
99  virtual bool isIsolateVertex(int id, bool& flag);
100 
101  /*!
102  \brief This function indicates if a desired element is a source vertex.
103 
104  \param id The attribute used to identify the vertex element
105 
106  \param flag Flag used to indicating if the element is a source vertex.
107 
108  \return True if the vertex element was found and false in other case
109  */
110  virtual bool isSourceVertex(int id, bool& flag);
111 
112  /*!
113  \brief This function indicates if a desired element is a sink vertex.
114 
115  \param id The attribute used to identify the vertex element
116 
117  \param flag Flag used to indicating if the element is a sink vertex.
118 
119  \return True if the vertex element was found and false in other case
120  */
121  virtual bool isSinkVertex(int id, bool& flag);
122 
123  //@}
124 
125  /** @name Edge Access Methods
126  * Method used to access edge elements from a graph.
127  */
128  //@{
129 
130  /*!
131  \brief Add a new edge element to a graph
132 
133  \param e Edge element
134 
135  \note This function turns the dirty flag of current GraphData to true, the
136  new flag of the edge turns to true.
137 
138  */
139  virtual void add(Edge* e);
140 
141  /*!
142  \brief This function removes the edge element from graph, also was removed
143  in data source.
144 
145  \param id Edge identification
146 
147  */
148  virtual void removeEdge(int id);
149 
150  /*!
151  \brief It returns all edges that came in a vertex
152 
153  \param vId The attribute used to identify the vertex element
154 
155  \return A vector with edge elements.
156  */
157  virtual std::vector<te::graph::Edge*> getInEdges(int vId);
158 
159  /*!
160  \brief It returns all edges that came out a vertex
161 
162  \param vId The attribute used to identify the vertex element
163 
164  \return A vector with edge elements.
165  */
166  virtual std::vector<te::graph::Edge*> getOutEdges(int vId);
167 
168  //@}
169 
170  };
171 
172  } // end namespace graph
173 } // end namespace te
174 
175 #endif // __TERRALIB_GRAPH_INTERNAL_BIDIRECTIONALGRAPH_H
Class used to define the edge struct of a graph. Its compose with a identifier, the vertex origin and...
Definition: Edge.h:58
#define TEGRAPHEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:216
This class define the main functions necessary to save and load the graph data and metadata informati...
This is the main graph implementation, that uses a cache policy anda graph loader to get all elements...
This is the main graph implementation, that uses a cache policy anda graph loader to get all elements...
Definition: Graph.h:72
This class is used to set the main functions of a cache policy.
This is a implementation of a Bidirectional Graph. By convention a bidirectional graph provides acces...