11 #ifndef BIOPROCESSING_GRAPH_BASEGRAPH
12 #define BIOPROCESSING_GRAPH_BASEGRAPH
15 #include <cartobase/smart/rcptr.h>
22 template <
typename E>
class BaseGraph;
23 template <
typename E>
class BaseGraphRef;
46 typedef typename Edge::Vertex
Vertex;
62 virtual bool empty()
const {
throw; }
97 template <
typename EdgeIterator>
98 bool isGraphCut( EdgeIterator begin, EdgeIterator end,
const Graph & g )
const {
throw; }
99 template <
typename EdgeSet>
104 template <
typename Set>
113 template <
typename G>
115 template <
typename G>
117 template <
typename VertexSet,
typename G>
119 template <
typename G>
120 static bool isSubGraph(
const G & thisg,
const typename G::Ref & g );
121 template <
typename G>
123 template <
typename G>
125 template <
typename G>
126 static bool isAdjacentTo(
const G & thisg,
const Vertex & v,
const typename G::Ref & g );
127 template <
typename G>
129 template <
typename G>
131 template <
typename G>
146 template <
typename E>
147 template <
typename G>
152 typename G::edge_const_iterator e;
153 for( e = thisg.beginEdge(x); e != thisg.endEdge(x); ++e )
154 if( e->other(x) == y )
159 template <
typename E>
160 template <
typename G>
167 std::set<Vertex> viewed;
169 typename G::edge_const_iterator e;
170 for( e = thisg.beginEdge(x); e != thisg.endEdge(x); ++e )
171 if( isLinked( thisg, e->other(x), y, viewed ) )
176 template <
typename E>
177 template <
typename VertexSet,
typename G>
185 if( s.insert( x ).second )
187 typename G::edge_const_iterator e;
188 for( e = thisg.beginEdge(x); e != thisg.endEdge(x); ++e )
189 if( isLinked( thisg, e->other(x), y, s ) )
195 template <
typename E>
196 template <
typename G>
198 const typename G::Ref & g )
203 typename G::vertex_const_iterator v;
204 for( v = g.beginVertex(); v != g.endVertex(); ++v )
205 if( !thisg.contains(*v) )
208 typename G::edge_const_iterator e;
209 for( e = g.beginEdge(); e != g.endEdge(); ++e )
210 if( !thisg.contains(*e) )
216 template <
typename E>
217 template <
typename G>
219 const typename G::Ref & g )
224 Vertex one = *( g.beginVertex() );
225 return g == thisg.getConnectedComponent( one );
228 template <
typename E>
229 template <
typename G>
233 return ( thisg.contains( e.x() ) || thisg.contains( e.y() ) ) && !thisg.contains( e );
236 template <
typename E>
237 template <
typename G>
240 const typename G::Ref & g )
242 typename G::edge_const_iterator e;
243 for( e = thisg.beginEdge(v); e != thisg.endEdge(v); ++e )
244 if( g.isAdjacent( *e ) )
249 template <
typename E>
250 template <
typename G>
253 const typename G::Ref & g )
255 typename G::edge_const_iterator e;
256 for( e = g.beginEdge(v); e != g.endEdge(v); ++e )
257 if( thisg.isAdjacent( *e ) )
262 template <
typename E>
263 template <
typename G>
268 thisg.getConnectedComponent( v, out );
272 template <
typename E>
273 template <
typename G>
276 typename G::Ref & g )
279 typename G::edge_iterator e;
280 for( e = thisg.beginEdge(v); e != thisg.endEdge(v); ++e ) {
282 if( !g.contains( e->other(v) ) )
283 thisg.getConnectedComponent( e->other(v), g );
289 template <
typename E>
290 template <
typename Set>
294 typename Set::const_iterator i;
295 for( i = e.begin(); i != e.end(); ++i ) {
310 template <
typename E>
315 typedef typename carto::rc_ptr<BaseGraph<E> >
Base;
339 virtual bool contains(
const Edge & e )
const {
return (*this)->contains(e); }
340 virtual bool empty()
const {
return (*this)->empty(); }
341 virtual void clear() {
return (*this)->clear(); }
347 if( !(*
this) && !other )
349 else if( !(*
this) || !other )
352 return *(this->get()) == *(other.get());
356 return !( *
this == other );
363 return this > &other;
370 return this < &other;
374 return ( *
this == other ) || ( *
this > other );
378 return ( *
this == other ) || ( *
this < other );
389 virtual bool isAdjacent(
const Edge & e )
const {
return (*this)->isAdjacent(e); }
394 virtual bool isTree(
const Graph & g )
const {
return (*this)->isTree(g); }
396 virtual bool isForest(
const Graph & g )
const {
return (*this)->isForest(g); }
398 template <
typename EdgeIterator>
399 bool isGraphCut( EdgeIterator begin, EdgeIterator end,
const Graph & g )
const {
return (*this)->isGraphCut(begin,end,g); }
400 template <
typename EdgeSet>
401 bool isGraphCut(
const EdgeSet & es,
const Graph & g )
const {
return (*this)->isGraphCut(es,g); }
405 template <
typename Set>
Reference to a BaseGraph.
virtual bool operator==(const This &other) const
carto::rc_ptr< BaseGraph< E > > Base
virtual bool contains(const Vertex &v) const
virtual void insert(Edge e)
static Set getComplement(const Set &s, const Set &e)
virtual bool operator>=(const This &other) const
virtual bool isLinked(const Vertex &v) const
virtual bool isAdjacent(const Vertex &x, const Vertex &y) const
virtual bool contains(const Edge &e) const
virtual bool isForest(const Graph &g) const
virtual bool isTree(const Graph &g) const
virtual void insert(Vertex v)
bool isGraphCut(EdgeIterator begin, EdgeIterator end, const Graph &g) const
virtual bool operator!=(const This &other) const
virtual bool isForestRelativeTo(const Graph &h, const Graph &g) const
virtual bool isAdjacent(const Edge &e) const
virtual bool isConnectedComponent(const Graph &g) const
virtual bool isLinked(const Vertex &x, const Vertex &y) const
virtual bool isExtension(const Graph &h, const Graph &g) const
virtual bool isSpanningTree(const Graph &g) const
virtual bool isSpanningForest(const Graph &g) const
virtual bool empty() const
virtual bool operator>(const This &other) const
virtual bool isAdjacentTo(const Vertex &v, const Graph &g) const
virtual bool isSpanningForestRelativeTo(const Graph &h, const Graph &g) const
virtual bool isSubGraph(const Graph &g) const
virtual bool isAdjacentFrom(const Vertex &v, const Graph &g) const
virtual bool operator<=(const This &other) const
bool isGraphCut(const EdgeSet &es, const Graph &g) const
BaseGraphRef(const Base &other)
virtual bool operator<(const This &other) const
virtual void insert(Vertex v)
bool isGraphCut(EdgeIterator begin, EdgeIterator end, const Graph &g) const
BaseGraphRef< E > Ref
Reference type.
virtual bool operator<(const This &other) const
BaseGraphRef< E > Graph
Usable graph type.
virtual bool isAdjacent(const Vertex &x, const Vertex &y) const
virtual bool operator!=(const This &other) const
virtual bool isForestRelativeTo(const Graph &h, const Graph &g) const
virtual bool isAdjacentFrom(const Vertex &v, const Graph &g) const
virtual bool contains(const Edge &e) const
virtual bool isSubGraph(const Graph &g) const
virtual bool isSpanningForestRelativeTo(const Graph &h, const Graph &g) const
virtual bool isSpanningTree(const Graph &g) const
virtual bool contains(const Vertex &v) const
static Set getComplement(const Set &s, const Set &e)
virtual bool operator>=(const This &other) const
virtual bool operator>(const This &other) const
virtual bool isForest(const Graph &g) const
virtual bool isLinked(const Vertex &x, const Vertex &y) const
virtual bool isLinked(const Vertex &v) const
bool isGraphCut(const EdgeSet &es, const Graph &g) const
virtual bool isConnectedComponent(const Graph &g) const
virtual bool isSpanningForest(const Graph &g) const
virtual bool empty() const
virtual bool operator<=(const This &other) const
static G::Ref getConnectedComponent(G &thisg, Vertex &v)
BaseGraph< E > This
Type of *this.
virtual bool isExtension(const Graph &h, const Graph &g) const
virtual bool operator=(const This &other)
virtual bool isAdjacent(const Edge &e) const
Edge::Vertex Vertex
Usable vertex type.
virtual bool isTree(const Graph &g) const
virtual void insert(Edge e)
virtual bool isAdjacentTo(const Vertex &v, const Graph &g) const
virtual bool operator==(const This &other) const