312 ///\warning Graph wrappers are in even more experimental state than the other |
313 ///\warning Graph wrappers are in even more experimental state than the other |
313 ///parts of the lib. Use them at you own risk. |
314 ///parts of the lib. Use them at you own risk. |
314 /// |
315 /// |
315 /// This wrapper shows a graph with filtered node-set and |
316 /// This wrapper shows a graph with filtered node-set and |
316 /// edge-set. Given a bool-valued map on the node-set and one on |
317 /// edge-set. Given a bool-valued map on the node-set and one on |
317 /// the edge-set of the graphs, the iterators shows only the objects |
318 /// the edge-set of the graphs, the iterators show only the objects |
318 /// having true value. |
319 /// having true value. |
319 /// The quick brown fox iterators jump over |
320 /// The quick brown fox iterators jump over |
320 /// the lazy dog nodes or edges if their values for are false in the |
321 /// the lazy dog nodes or edges if their values for are false in the |
321 /// corresponding bool maps. |
322 /// corresponding bool maps. |
322 /// |
323 /// |
575 |
576 |
576 // KEEP_MAPS(Parent, UndirGraphWrapper); |
577 // KEEP_MAPS(Parent, UndirGraphWrapper); |
577 |
578 |
578 }; |
579 }; |
579 |
580 |
580 /// \brief An undirected graph template. |
581 // /// \brief An undirected graph template. |
581 /// |
582 // /// |
582 ///\warning Graph wrappers are in even more experimental state than the other |
583 // ///\warning Graph wrappers are in even more experimental state than the other |
583 ///parts of the lib. Use them at your own risk. |
584 // ///parts of the lib. Use them at your own risk. |
584 /// |
585 // /// |
585 /// An undirected graph template. |
586 // /// An undirected graph template. |
586 /// This class works as an undirected graph and a directed graph of |
587 // /// This class works as an undirected graph and a directed graph of |
587 /// class \c Graph is used for the physical storage. |
588 // /// class \c Graph is used for the physical storage. |
588 /// \ingroup graphs |
589 // /// \ingroup graphs |
589 template<typename Graph> |
590 template<typename Graph> |
590 class UndirGraph : public UndirGraphWrapper<Graph> { |
591 class UndirGraph : public UndirGraphWrapper<Graph> { |
591 typedef UndirGraphWrapper<Graph> Parent; |
592 typedef UndirGraphWrapper<Graph> Parent; |
592 protected: |
593 protected: |
593 Graph gr; |
594 Graph gr; |
606 /// |
607 /// |
607 ///\warning Graph wrappers are in even more experimental state than the other |
608 ///\warning Graph wrappers are in even more experimental state than the other |
608 ///parts of the lib. Use them at you own risk. |
609 ///parts of the lib. Use them at you own risk. |
609 /// |
610 /// |
610 /// Suppose that for a directed graph $G=(V, A)$, |
611 /// Suppose that for a directed graph $G=(V, A)$, |
611 /// two predicates on the edge-set, $forward_filter$, and $backward_filter$ |
612 /// two bool valued maps on the edge-set, |
|
613 /// $forward_filter$, and $backward_filter$ |
612 /// is given, and we are dealing with the directed graph |
614 /// is given, and we are dealing with the directed graph |
613 /// a $G'=(V, \{uv : uv\in A \mbox{ and } forward_filter(uv) \mbox{ is true}\}+\{vu : uv\in A \mbox{ and } backward_filter(uv) \mbox{ is true}\})$. |
615 /// a $G'=(V, \{uv : uv\in A \mbox{ and } forward_filter(uv) \mbox{ is true}\}+\{vu : uv\in A \mbox{ and } backward_filter(uv) \mbox{ is true}\})$. |
614 /// The purpose of writing + instead of union is because parallel |
616 /// The purpose of writing + instead of union is because parallel |
615 /// edges can arose. |
617 /// edges can arose. |
616 /// In other words, a subgraph of the bidirected graph obtained, which |
618 /// In other words, a subgraph of the bidirected graph obtained, which |
619 /// forward_filter is everywhere false and the backward_filter is |
621 /// forward_filter is everywhere false and the backward_filter is |
620 /// everywhere true. We note that for sake of efficiency, |
622 /// everywhere true. We note that for sake of efficiency, |
621 /// \c RevGraphWrapper is implemented in a different way. |
623 /// \c RevGraphWrapper is implemented in a different way. |
622 /// But BidirGraphWrapper is obtained from |
624 /// But BidirGraphWrapper is obtained from |
623 /// SubBidirGraphWrapper by considering everywhere true |
625 /// SubBidirGraphWrapper by considering everywhere true |
624 /// predicates both forward_filter and backward_filter. |
626 /// valued maps both for forward_filter and backward_filter. |
625 /// Finally, one of the most important applications of SubBidirGraphWrapper |
627 /// Finally, one of the most important applications of SubBidirGraphWrapper |
626 /// is ResGraphWrapper, which stands for the residual graph in directed |
628 /// is ResGraphWrapper, which stands for the residual graph in directed |
627 /// flow and circulation problems. |
629 /// flow and circulation problems. |
628 /// As wrappers usually, the SubBidirGraphWrapper implements the |
630 /// As wrappers usually, the SubBidirGraphWrapper implements the |
629 /// above mentioned graph structure without its physical storage, |
631 /// above mentioned graph structure without its physical storage, |
630 /// that is the whole stuff eats constant memory. |
632 /// that is the whole stuff eats constant memory. |
631 /// As the oppositely directed edges are logical different, |
633 /// As the oppositely directed edges are logically different, |
632 /// the maps are able to attach different values for them. |
634 /// the maps are able to attach different values for them. |
633 template<typename Graph, |
635 template<typename Graph, |
634 typename ForwardFilterMap, typename BackwardFilterMap> |
636 typename ForwardFilterMap, typename BackwardFilterMap> |
635 class SubBidirGraphWrapper : public GraphWrapper<Graph> { |
637 class SubBidirGraphWrapper : public GraphWrapper<Graph> { |
636 public: |
638 public: |
668 |
670 |
669 typedef typename GraphWrapper<Graph>::Node Node; |
671 typedef typename GraphWrapper<Graph>::Node Node; |
670 |
672 |
671 typedef typename Graph::Edge GraphEdge; |
673 typedef typename Graph::Edge GraphEdge; |
672 /// SubBidirGraphWrapper<..., ..., ...>::Edge is inherited from |
674 /// SubBidirGraphWrapper<..., ..., ...>::Edge is inherited from |
673 /// Graph::Edge. It contains an extra bool flag which shows if the |
675 /// Graph::Edge. It contains an extra bool flag which is true |
|
676 /// if and only if the |
674 /// edge is the backward version of the original edge. |
677 /// edge is the backward version of the original edge. |
675 class Edge : public Graph::Edge { |
678 class Edge : public Graph::Edge { |
676 friend class SubBidirGraphWrapper<Graph, |
679 friend class SubBidirGraphWrapper<Graph, |
677 ForwardFilterMap, BackwardFilterMap>; |
680 ForwardFilterMap, BackwardFilterMap>; |
678 template<typename T> friend class EdgeMap; |
681 template<typename T> friend class EdgeMap; |
1128 flow->set(e, (*flow)[e]-a); |
1131 flow->set(e, (*flow)[e]-a); |
1129 } |
1132 } |
1130 |
1133 |
1131 /// \brief Residual capacity map. |
1134 /// \brief Residual capacity map. |
1132 /// |
1135 /// |
1133 /// In generic residual graphs the residual capacity can be obtained as a map. Not tested. |
1136 /// In generic residual graphs the residual capacity can be obtained |
|
1137 /// as a map. |
1134 class ResCap { |
1138 class ResCap { |
1135 protected: |
1139 protected: |
1136 const ResGraphWrapper<Graph, Number, CapacityMap, FlowMap>* res_graph; |
1140 const ResGraphWrapper<Graph, Number, CapacityMap, FlowMap>* res_graph; |
1137 public: |
1141 public: |
1138 typedef Number ValueType; |
1142 typedef Number ValueType; |