equal
deleted
inserted
replaced
80 ///Base type for the Graph Wrappers |
80 ///Base type for the Graph Wrappers |
81 |
81 |
82 ///This is the base type for the Graph Wrappers. |
82 ///This is the base type for the Graph Wrappers. |
83 ///\todo Some more docs... |
83 ///\todo Some more docs... |
84 /// |
84 /// |
85 ///\author Marton Makai |
85 ///\author Marton Makai |
86 |
|
87 template<typename Graph> |
86 template<typename Graph> |
88 class GraphWrapper { |
87 class GraphWrapper { |
89 protected: |
88 protected: |
90 Graph* graph; |
89 Graph* graph; |
91 GraphWrapper() : graph(0) { } |
90 GraphWrapper() : graph(0) { } |
221 |
220 |
222 |
221 |
223 /// A graph wrapper which reverses the orientation of the edges. |
222 /// A graph wrapper which reverses the orientation of the edges. |
224 |
223 |
225 /// A graph wrapper which reverses the orientation of the edges. |
224 /// A graph wrapper which reverses the orientation of the edges. |
|
225 /// Thus \c Graph have to be a directed graph type. |
226 /// |
226 /// |
227 ///\author Marton Makai |
227 ///\author Marton Makai |
228 template<typename Graph> |
228 template<typename Graph> |
229 class RevGraphWrapper : public GraphWrapper<Graph> { |
229 class RevGraphWrapper : public GraphWrapper<Graph> { |
230 protected: |
230 protected: |
231 RevGraphWrapper() : GraphWrapper<Graph>(0) { } |
231 RevGraphWrapper() : GraphWrapper<Graph>() { } |
232 public: |
232 public: |
233 RevGraphWrapper(Graph& _graph) : GraphWrapper<Graph>(_graph) { } |
233 RevGraphWrapper(Graph& _graph) : GraphWrapper<Graph>(_graph) { } |
234 |
234 |
235 typedef typename GraphWrapper<Graph>::Node Node; |
235 typedef typename GraphWrapper<Graph>::Node Node; |
236 typedef typename GraphWrapper<Graph>::Edge Edge; |
236 typedef typename GraphWrapper<Graph>::Edge Edge; |
294 |
294 |
295 }; |
295 }; |
296 |
296 |
297 |
297 |
298 |
298 |
299 /// Wrapper for hiding nodes and edges from a graph. |
299 /// A graph wrapper for hiding nodes and edges from a graph. |
300 |
300 |
301 /// This wrapper shows a graph with filtered node-set and |
301 /// This wrapper shows a graph with filtered node-set and |
302 /// edge-set. The quick brown fox iterator jumps over |
302 /// edge-set. The quick brown fox iterator jumps over |
303 /// the lazy dog nodes or edges if the values for them are false |
303 /// the lazy dog nodes or edges if the values for them are false |
304 /// in the bool maps. |
304 /// in the bool maps. |
309 class SubGraphWrapper : public GraphWrapper<Graph> { |
309 class SubGraphWrapper : public GraphWrapper<Graph> { |
310 protected: |
310 protected: |
311 NodeFilterMap* node_filter_map; |
311 NodeFilterMap* node_filter_map; |
312 EdgeFilterMap* edge_filter_map; |
312 EdgeFilterMap* edge_filter_map; |
313 |
313 |
314 SubGraphWrapper() : GraphWrapper<Graph>(0), |
314 SubGraphWrapper() : GraphWrapper<Graph>(), |
315 node_filter_map(0), edge_filter_map(0) { } |
315 node_filter_map(0), edge_filter_map(0) { } |
316 void setNodeFilterMap(NodeFilterMap& _node_filter_map) { |
316 void setNodeFilterMap(NodeFilterMap& _node_filter_map) { |
317 node_filter_map=&_node_filter_map; |
317 node_filter_map=&_node_filter_map; |
318 } |
318 } |
319 void setEdgeFilterMap(EdgeFilterMap& _edge_filter_map) { |
319 void setEdgeFilterMap(EdgeFilterMap& _edge_filter_map) { |
486 |
486 |
487 }; |
487 }; |
488 |
488 |
489 |
489 |
490 |
490 |
491 /// A wrapper for forgetting the orientation of a graph. |
491 /// \brief A wrapper for forgetting the orientation of a graph. |
492 |
492 /// |
493 /// A wrapper for getting an undirected graph by forgetting |
493 /// A wrapper for getting an undirected graph by forgetting |
494 /// the orientation of a directed one. |
494 /// the orientation of a directed one. |
495 /// |
495 /// |
496 ///\author Marton Makai |
496 /// \author Marton Makai |
497 template<typename Graph> |
497 template<typename Graph> |
498 class UndirGraphWrapper : public GraphWrapper<Graph> { |
498 class UndirGraphWrapper : public GraphWrapper<Graph> { |
499 protected: |
499 protected: |
500 UndirGraphWrapper() : GraphWrapper<Graph>() { } |
500 UndirGraphWrapper() : GraphWrapper<Graph>() { } |
501 |
501 |
571 Node bNode(const OutEdgeIt& e) const { |
571 Node bNode(const OutEdgeIt& e) const { |
572 if (e.out_or_in) return this->graph->head(e); else |
572 if (e.out_or_in) return this->graph->head(e); else |
573 return this->graph->tail(e); } |
573 return this->graph->tail(e); } |
574 }; |
574 }; |
575 |
575 |
576 |
576 /// \brief An undirected graph template. |
577 |
577 /// |
578 /// An undirected graph template |
578 /// An undirected graph template. |
|
579 /// This class works as an undirected graph and a directed graph of |
|
580 /// class \c Graph is used for the physical storage. |
|
581 /// \ingroup graphs |
579 template<typename Graph> |
582 template<typename Graph> |
580 class UndirGraph : public UndirGraphWrapper<Graph> { |
583 class UndirGraph : public UndirGraphWrapper<Graph> { |
581 typedef UndirGraphWrapper<Graph> Parent; |
584 typedef UndirGraphWrapper<Graph> Parent; |
582 protected: |
585 protected: |
583 Graph gr; |
586 Graph gr; |
586 Parent::setGraph(gr); |
589 Parent::setGraph(gr); |
587 } |
590 } |
588 }; |
591 }; |
589 |
592 |
590 |
593 |
|
594 ///\brief A wrapper for composing bidirected graph from a directed one. |
|
595 /// experimental, for fezso's sake. |
|
596 /// |
591 /// A wrapper for composing bidirected graph from a directed one. |
597 /// A wrapper for composing bidirected graph from a directed one. |
592 /// experimental, for fezso's sake. |
598 /// experimental, for fezso's sake. |
593 |
599 /// A bidirected graph is composed over the directed one without physical |
594 /// A wrapper for composing bidirected graph from a directed one. |
600 /// storage. As the oppositely directed edges are logically different ones |
595 /// experimental, for fezso's sake. |
601 /// the maps are able to attach different values for them. |
596 template<typename Graph> |
602 template<typename Graph> |
597 class BidirGraphWrapper : public GraphWrapper<Graph> { |
603 class BidirGraphWrapper : public GraphWrapper<Graph> { |
598 protected: |
604 protected: |
599 //const CapacityMap* capacity; |
605 //const CapacityMap* capacity; |
600 //FlowMap* flow; |
606 //FlowMap* flow; |
908 // return backward_map.get(e.in); |
914 // return backward_map.get(e.in); |
909 // } |
915 // } |
910 }; |
916 }; |
911 }; |
917 }; |
912 |
918 |
|
919 /// \brief A bidirected graph template. |
|
920 /// |
|
921 /// A bidirected graph template. |
|
922 /// Such a bidirected graph stores each pair of oppositely directed edges |
|
923 /// ones in the memory, i.e. a directed graph of type |
|
924 /// \c Graph is used for that. |
|
925 /// As the oppositely directed edges are logically different ones |
|
926 /// the maps are able to attach different values for them. |
|
927 /// \ingroup graphs |
|
928 template<typename Graph> |
|
929 class BidirGraph : public BidirGraphWrapper<Graph> { |
|
930 typedef UndirGraphWrapper<Graph> Parent; |
|
931 protected: |
|
932 Graph gr; |
|
933 public: |
|
934 BidirGraph() : BidirGraphWrapper<Graph>() { |
|
935 Parent::setGraph(gr); |
|
936 } |
|
937 }; |
913 |
938 |
914 |
939 |
915 /// A wrapper for composing the residual graph for directed flow and circulation problems. |
940 /// A wrapper for composing the residual graph for directed flow and circulation problems. |
916 |
941 |
917 /// A wrapper for composing the residual graph for directed flow and circulation problems. |
942 /// A wrapper for composing the residual graph for directed flow and circulation problems. |
1224 }; |
1249 }; |
1225 }; |
1250 }; |
1226 |
1251 |
1227 |
1252 |
1228 |
1253 |
1229 /// ErasingFirstGraphWrapper for blocking flows. |
1254 /// For blocking flows. |
1230 |
1255 |
1231 /// ErasingFirstGraphWrapper for blocking flows. |
1256 /// This graph wrapper is used for Dinits blocking flow computations. |
|
1257 /// For each node, an out-edge is stored which is used when the |
|
1258 /// \code |
|
1259 /// OutEdgeIt& first(OutEdgeIt&, const Node&) |
|
1260 /// \endcode |
|
1261 /// is called. |
1232 /// |
1262 /// |
1233 ///\author Marton Makai |
1263 ///\author Marton Makai |
1234 template<typename Graph, typename FirstOutEdgesMap> |
1264 template<typename Graph, typename FirstOutEdgesMap> |
1235 class ErasingFirstGraphWrapper : public GraphWrapper<Graph> { |
1265 class ErasingFirstGraphWrapper : public GraphWrapper<Graph> { |
1236 protected: |
1266 protected: |