683 |
694 |
684 }; |
695 }; |
685 |
696 |
686 /// \ingroup graph_adaptors |
697 /// \ingroup graph_adaptors |
687 /// |
698 /// |
688 /// \brief An adaptor for hiding nodes and arcs in a digraph |
699 /// \brief Adaptor class for hiding nodes and arcs in a digraph |
689 /// |
700 /// |
690 /// SubDigraph hides nodes and arcs in a digraph. A bool node map |
701 /// SubDigraph can be used for hiding nodes and arcs in a digraph. |
691 /// and a bool arc map must be specified, which define the filters |
702 /// A \c bool node map and a \c bool arc map must be specified, which |
692 /// for nodes and arcs. Just the nodes and arcs with true value are |
703 /// define the filters for nodes and arcs. |
693 /// shown in the subdigraph. The SubDigraph is conform to the \ref |
704 /// Only the nodes and arcs with \c true filter value are |
694 /// concepts::Digraph "Digraph concept". If the \c _checked parameter |
705 /// shown in the subdigraph. This adaptor conforms to the \ref |
695 /// is true, then the arcs incident to filtered nodes are also |
706 /// concepts::Digraph "Digraph" concept. If the \c _checked parameter |
|
707 /// is \c true, then the arcs incident to hidden nodes are also |
696 /// filtered out. |
708 /// filtered out. |
697 /// |
709 /// |
698 /// \tparam _Digraph It must be conform to the \ref |
710 /// The adapted digraph can also be modified through this adaptor |
699 /// concepts::Digraph "Digraph concept". The type can be specified |
711 /// by adding or removing nodes or arcs, unless the \c _Digraph template |
700 /// to const. |
712 /// parameter is set to be \c const. |
701 /// \tparam _NodeFilterMap A bool valued node map of the the adapted digraph. |
713 /// |
702 /// \tparam _ArcFilterMap A bool valued arc map of the the adapted digraph. |
714 /// \tparam _Digraph The type of the adapted digraph. |
703 /// \tparam _checked If the parameter is false then the arc filtering |
715 /// It must conform to the \ref concepts::Digraph "Digraph" concept. |
704 /// is not checked with respect to node filter. Otherwise, each arc |
716 /// It can also be specified to be \c const. |
705 /// is automatically filtered, which is incident to a filtered node. |
717 /// \tparam _NodeFilterMap A \c bool (or convertible) node map of the |
|
718 /// adapted digraph. The default map type is |
|
719 /// \ref concepts::Digraph::NodeMap "_Digraph::NodeMap<bool>". |
|
720 /// \tparam _ArcFilterMap A \c bool (or convertible) arc map of the |
|
721 /// adapted digraph. The default map type is |
|
722 /// \ref concepts::Digraph::ArcMap "_Digraph::ArcMap<bool>". |
|
723 /// \tparam _checked If this parameter is set to \c false, then the arc |
|
724 /// filtering is not checked with respect to the node filter. |
|
725 /// Otherwise, each arc that is incident to a hidden node is automatically |
|
726 /// filtered out. This is the default option. |
|
727 /// |
|
728 /// \note The \c Node and \c Arc types of this adaptor and the adapted |
|
729 /// digraph are convertible to each other. |
706 /// |
730 /// |
707 /// \see FilterNodes |
731 /// \see FilterNodes |
708 /// \see FilterArcs |
732 /// \see FilterArcs |
|
733 #ifdef DOXYGEN |
|
734 template<typename _Digraph, |
|
735 typename _NodeFilterMap, |
|
736 typename _ArcFilterMap, |
|
737 bool _checked> |
|
738 #else |
709 template<typename _Digraph, |
739 template<typename _Digraph, |
710 typename _NodeFilterMap = typename _Digraph::template NodeMap<bool>, |
740 typename _NodeFilterMap = typename _Digraph::template NodeMap<bool>, |
711 typename _ArcFilterMap = typename _Digraph::template ArcMap<bool>, |
741 typename _ArcFilterMap = typename _Digraph::template ArcMap<bool>, |
712 bool _checked = true> |
742 bool _checked = true> |
|
743 #endif |
713 class SubDigraph |
744 class SubDigraph |
714 : public DigraphAdaptorExtender< |
745 : public DigraphAdaptorExtender< |
715 SubDigraphBase<_Digraph, _NodeFilterMap, _ArcFilterMap, _checked> > { |
746 SubDigraphBase<_Digraph, _NodeFilterMap, _ArcFilterMap, _checked> > { |
716 public: |
747 public: |
|
748 /// The type of the adapted digraph. |
717 typedef _Digraph Digraph; |
749 typedef _Digraph Digraph; |
|
750 /// The type of the node filter map. |
718 typedef _NodeFilterMap NodeFilterMap; |
751 typedef _NodeFilterMap NodeFilterMap; |
|
752 /// The type of the arc filter map. |
719 typedef _ArcFilterMap ArcFilterMap; |
753 typedef _ArcFilterMap ArcFilterMap; |
720 |
754 |
721 typedef DigraphAdaptorExtender< |
755 typedef DigraphAdaptorExtender< |
722 SubDigraphBase<Digraph, NodeFilterMap, ArcFilterMap, _checked> > |
756 SubDigraphBase<_Digraph, _NodeFilterMap, _ArcFilterMap, _checked> > |
723 Parent; |
757 Parent; |
724 |
758 |
725 typedef typename Parent::Node Node; |
759 typedef typename Parent::Node Node; |
726 typedef typename Parent::Arc Arc; |
760 typedef typename Parent::Arc Arc; |
727 |
761 |
729 SubDigraph() { } |
763 SubDigraph() { } |
730 public: |
764 public: |
731 |
765 |
732 /// \brief Constructor |
766 /// \brief Constructor |
733 /// |
767 /// |
734 /// Creates a subdigraph for the given digraph with |
768 /// Creates a subdigraph for the given digraph with the |
735 /// given node and arc map filters. |
769 /// given node and arc filter maps. |
736 SubDigraph(Digraph& digraph, NodeFilterMap& node_filter, |
770 SubDigraph(Digraph& digraph, NodeFilterMap& node_filter, |
737 ArcFilterMap& arc_filter) { |
771 ArcFilterMap& arc_filter) { |
738 setDigraph(digraph); |
772 setDigraph(digraph); |
739 setNodeFilterMap(node_filter); |
773 setNodeFilterMap(node_filter); |
740 setArcFilterMap(arc_filter); |
774 setArcFilterMap(arc_filter); |
741 } |
775 } |
742 |
776 |
743 /// \brief Hides the node of the graph |
777 /// \brief Hides the given node |
744 /// |
778 /// |
745 /// This function hides \c n in the digraph, i.e. the iteration |
779 /// This function hides the given node in the subdigraph, |
746 /// jumps over it. This is done by simply setting the value of \c n |
780 /// i.e. the iteration jumps over it. |
747 /// to be false in the corresponding node-map. |
781 /// It is done by simply setting the assigned value of \c n |
|
782 /// to be \c false in the node filter map. |
748 void hide(const Node& n) const { Parent::hide(n); } |
783 void hide(const Node& n) const { Parent::hide(n); } |
749 |
784 |
750 /// \brief Hides the arc of the graph |
785 /// \brief Hides the given arc |
751 /// |
786 /// |
752 /// This function hides \c a in the digraph, i.e. the iteration |
787 /// This function hides the given arc in the subdigraph, |
753 /// jumps over it. This is done by simply setting the value of \c a |
788 /// i.e. the iteration jumps over it. |
754 /// to be false in the corresponding arc-map. |
789 /// It is done by simply setting the assigned value of \c a |
|
790 /// to be \c false in the arc filter map. |
755 void hide(const Arc& a) const { Parent::hide(a); } |
791 void hide(const Arc& a) const { Parent::hide(a); } |
756 |
792 |
757 /// \brief Unhides the node of the graph |
793 /// \brief Shows the given node |
758 /// |
794 /// |
759 /// The value of \c n is set to be true in the node-map which stores |
795 /// This function shows the given node in the subdigraph. |
760 /// hide information. If \c n was hidden previuosly, then it is shown |
796 /// It is done by simply setting the assigned value of \c n |
761 /// again |
797 /// to be \c true in the node filter map. |
762 void unHide(const Node& n) const { Parent::unHide(n); } |
798 void unHide(const Node& n) const { Parent::unHide(n); } |
763 |
799 |
764 /// \brief Unhides the arc of the graph |
800 /// \brief Shows the given arc |
765 /// |
801 /// |
766 /// The value of \c a is set to be true in the arc-map which stores |
802 /// This function shows the given arc in the subdigraph. |
767 /// hide information. If \c a was hidden previuosly, then it is shown |
803 /// It is done by simply setting the assigned value of \c a |
768 /// again |
804 /// to be \c true in the arc filter map. |
769 void unHide(const Arc& a) const { Parent::unHide(a); } |
805 void unHide(const Arc& a) const { Parent::unHide(a); } |
770 |
806 |
771 /// \brief Returns true if \c n is hidden. |
807 /// \brief Returns \c true if the given node is hidden. |
772 /// |
808 /// |
773 /// Returns true if \c n is hidden. |
809 /// This function returns \c true if the given node is hidden. |
774 /// |
|
775 bool hidden(const Node& n) const { return Parent::hidden(n); } |
810 bool hidden(const Node& n) const { return Parent::hidden(n); } |
776 |
811 |
777 /// \brief Returns true if \c a is hidden. |
812 /// \brief Returns \c true if the given arc is hidden. |
778 /// |
813 /// |
779 /// Returns true if \c a is hidden. |
814 /// This function returns \c true if the given arc is hidden. |
780 /// |
|
781 bool hidden(const Arc& a) const { return Parent::hidden(a); } |
815 bool hidden(const Arc& a) const { return Parent::hidden(a); } |
782 |
816 |
783 }; |
817 }; |
784 |
818 |
785 /// \brief Just gives back a subdigraph |
819 /// \brief Returns a read-only SubDigraph adaptor |
786 /// |
820 /// |
787 /// Just gives back a subdigraph |
821 /// This function just returns a read-only \ref SubDigraph adaptor. |
|
822 /// \ingroup graph_adaptors |
|
823 /// \relates SubDigraph |
788 template<typename Digraph, typename NodeFilterMap, typename ArcFilterMap> |
824 template<typename Digraph, typename NodeFilterMap, typename ArcFilterMap> |
789 SubDigraph<const Digraph, NodeFilterMap, ArcFilterMap> |
825 SubDigraph<const Digraph, NodeFilterMap, ArcFilterMap> |
790 subDigraph(const Digraph& digraph, NodeFilterMap& nfm, ArcFilterMap& afm) { |
826 subDigraph(const Digraph& digraph, NodeFilterMap& nfm, ArcFilterMap& afm) { |
791 return SubDigraph<const Digraph, NodeFilterMap, ArcFilterMap> |
827 return SubDigraph<const Digraph, NodeFilterMap, ArcFilterMap> |
792 (digraph, nfm, afm); |
828 (digraph, nfm, afm); |
1247 |
1283 |
1248 }; |
1284 }; |
1249 |
1285 |
1250 /// \ingroup graph_adaptors |
1286 /// \ingroup graph_adaptors |
1251 /// |
1287 /// |
1252 /// \brief A graph adaptor for hiding nodes and edges in an |
1288 /// \brief Adaptor class for hiding nodes and edges in an undirected |
1253 /// undirected graph. |
1289 /// graph. |
1254 /// |
1290 /// |
1255 /// SubGraph hides nodes and edges in a graph. A bool node map and a |
1291 /// SubGraph can be used for hiding nodes and edges in a graph. |
1256 /// bool edge map must be specified, which define the filters for |
1292 /// A \c bool node map and a \c bool edge map must be specified, which |
1257 /// nodes and edges. Just the nodes and edges with true value are |
1293 /// define the filters for nodes and edges. |
1258 /// shown in the subgraph. The SubGraph is conform to the \ref |
1294 /// Only the nodes and edges with \c true filter value are |
1259 /// concepts::Graph "Graph concept". If the \c _checked parameter is |
1295 /// shown in the subgraph. This adaptor conforms to the \ref |
1260 /// true, then the edges incident to filtered nodes are also |
1296 /// concepts::Graph "Graph" concept. If the \c _checked parameter is |
|
1297 /// \c true, then the edges incident to hidden nodes are also |
1261 /// filtered out. |
1298 /// filtered out. |
1262 /// |
1299 /// |
1263 /// \tparam _Graph It must be conform to the \ref |
1300 /// The adapted graph can also be modified through this adaptor |
1264 /// concepts::Graph "Graph concept". The type can be specified |
1301 /// by adding or removing nodes or edges, unless the \c _Graph template |
1265 /// to const. |
1302 /// parameter is set to be \c const. |
1266 /// \tparam _NodeFilterMap A bool valued node map of the the adapted graph. |
1303 /// |
1267 /// \tparam _EdgeFilterMap A bool valued edge map of the the adapted graph. |
1304 /// \tparam _Graph The type of the adapted graph. |
1268 /// \tparam _checked If the parameter is false then the edge filtering |
1305 /// It must conform to the \ref concepts::Graph "Graph" concept. |
1269 /// is not checked with respect to node filter. Otherwise, each edge |
1306 /// It can also be specified to be \c const. |
1270 /// is automatically filtered, which is incident to a filtered node. |
1307 /// \tparam _NodeFilterMap A \c bool (or convertible) node map of the |
|
1308 /// adapted graph. The default map type is |
|
1309 /// \ref concepts::Graph::NodeMap "_Graph::NodeMap<bool>". |
|
1310 /// \tparam _EdgeFilterMap A \c bool (or convertible) edge map of the |
|
1311 /// adapted graph. The default map type is |
|
1312 /// \ref concepts::Graph::EdgeMap "_Graph::EdgeMap<bool>". |
|
1313 /// \tparam _checked If this parameter is set to \c false, then the edge |
|
1314 /// filtering is not checked with respect to the node filter. |
|
1315 /// Otherwise, each edge that is incident to a hidden node is automatically |
|
1316 /// filtered out. This is the default option. |
|
1317 /// |
|
1318 /// \note The \c Node, \c Edge and \c Arc types of this adaptor and the |
|
1319 /// adapted graph are convertible to each other. |
1271 /// |
1320 /// |
1272 /// \see FilterNodes |
1321 /// \see FilterNodes |
1273 /// \see FilterEdges |
1322 /// \see FilterEdges |
1274 template<typename _Graph, typename NodeFilterMap, |
1323 #ifdef DOXYGEN |
1275 typename EdgeFilterMap, bool _checked = true> |
1324 template<typename _Graph, |
|
1325 typename _NodeFilterMap, |
|
1326 typename _EdgeFilterMap, |
|
1327 bool _checked> |
|
1328 #else |
|
1329 template<typename _Graph, |
|
1330 typename _NodeFilterMap = typename _Graph::template NodeMap<bool>, |
|
1331 typename _EdgeFilterMap = typename _Graph::template EdgeMap<bool>, |
|
1332 bool _checked = true> |
|
1333 #endif |
1276 class SubGraph |
1334 class SubGraph |
1277 : public GraphAdaptorExtender< |
1335 : public GraphAdaptorExtender< |
1278 SubGraphBase<_Graph, NodeFilterMap, EdgeFilterMap, _checked> > { |
1336 SubGraphBase<_Graph, _NodeFilterMap, _EdgeFilterMap, _checked> > { |
1279 public: |
1337 public: |
|
1338 /// The type of the adapted graph. |
1280 typedef _Graph Graph; |
1339 typedef _Graph Graph; |
|
1340 /// The type of the node filter map. |
|
1341 typedef _NodeFilterMap NodeFilterMap; |
|
1342 /// The type of the edge filter map. |
|
1343 typedef _EdgeFilterMap EdgeFilterMap; |
|
1344 |
1281 typedef GraphAdaptorExtender< |
1345 typedef GraphAdaptorExtender< |
1282 SubGraphBase<_Graph, NodeFilterMap, EdgeFilterMap> > Parent; |
1346 SubGraphBase<_Graph, _NodeFilterMap, _EdgeFilterMap, _checked> > Parent; |
1283 |
1347 |
1284 typedef typename Parent::Node Node; |
1348 typedef typename Parent::Node Node; |
1285 typedef typename Parent::Edge Edge; |
1349 typedef typename Parent::Edge Edge; |
1286 |
1350 |
1287 protected: |
1351 protected: |
1288 SubGraph() { } |
1352 SubGraph() { } |
1289 public: |
1353 public: |
1290 |
1354 |
1291 /// \brief Constructor |
1355 /// \brief Constructor |
1292 /// |
1356 /// |
1293 /// Creates a subgraph for the given graph with given node and |
1357 /// Creates a subgraph for the given graph with the given node |
1294 /// edge map filters. |
1358 /// and edge filter maps. |
1295 SubGraph(Graph& _graph, NodeFilterMap& node_filter_map, |
1359 SubGraph(Graph& graph, NodeFilterMap& node_filter_map, |
1296 EdgeFilterMap& edge_filter_map) { |
1360 EdgeFilterMap& edge_filter_map) { |
1297 setGraph(_graph); |
1361 setGraph(graph); |
1298 setNodeFilterMap(node_filter_map); |
1362 setNodeFilterMap(node_filter_map); |
1299 setEdgeFilterMap(edge_filter_map); |
1363 setEdgeFilterMap(edge_filter_map); |
1300 } |
1364 } |
1301 |
1365 |
1302 /// \brief Hides the node of the graph |
1366 /// \brief Hides the given node |
1303 /// |
1367 /// |
1304 /// This function hides \c n in the graph, i.e. the iteration |
1368 /// This function hides the given node in the subgraph, |
1305 /// jumps over it. This is done by simply setting the value of \c n |
1369 /// i.e. the iteration jumps over it. |
1306 /// to be false in the corresponding node-map. |
1370 /// It is done by simply setting the assigned value of \c n |
|
1371 /// to be \c false in the node filter map. |
1307 void hide(const Node& n) const { Parent::hide(n); } |
1372 void hide(const Node& n) const { Parent::hide(n); } |
1308 |
1373 |
1309 /// \brief Hides the edge of the graph |
1374 /// \brief Hides the given edge |
1310 /// |
1375 /// |
1311 /// This function hides \c e in the graph, i.e. the iteration |
1376 /// This function hides the given edge in the subgraph, |
1312 /// jumps over it. This is done by simply setting the value of \c e |
1377 /// i.e. the iteration jumps over it. |
1313 /// to be false in the corresponding edge-map. |
1378 /// It is done by simply setting the assigned value of \c e |
|
1379 /// to be \c false in the edge filter map. |
1314 void hide(const Edge& e) const { Parent::hide(e); } |
1380 void hide(const Edge& e) const { Parent::hide(e); } |
1315 |
1381 |
1316 /// \brief Unhides the node of the graph |
1382 /// \brief Shows the given node |
1317 /// |
1383 /// |
1318 /// The value of \c n is set to be true in the node-map which stores |
1384 /// This function shows the given node in the subgraph. |
1319 /// hide information. If \c n was hidden previuosly, then it is shown |
1385 /// It is done by simply setting the assigned value of \c n |
1320 /// again |
1386 /// to be \c true in the node filter map. |
1321 void unHide(const Node& n) const { Parent::unHide(n); } |
1387 void unHide(const Node& n) const { Parent::unHide(n); } |
1322 |
1388 |
1323 /// \brief Unhides the edge of the graph |
1389 /// \brief Shows the given edge |
1324 /// |
1390 /// |
1325 /// The value of \c e is set to be true in the edge-map which stores |
1391 /// This function shows the given edge in the subgraph. |
1326 /// hide information. If \c e was hidden previuosly, then it is shown |
1392 /// It is done by simply setting the assigned value of \c e |
1327 /// again |
1393 /// to be \c true in the edge filter map. |
1328 void unHide(const Edge& e) const { Parent::unHide(e); } |
1394 void unHide(const Edge& e) const { Parent::unHide(e); } |
1329 |
1395 |
1330 /// \brief Returns true if \c n is hidden. |
1396 /// \brief Returns \c true if the given node is hidden. |
1331 /// |
1397 /// |
1332 /// Returns true if \c n is hidden. |
1398 /// This function returns \c true if the given node is hidden. |
1333 /// |
|
1334 bool hidden(const Node& n) const { return Parent::hidden(n); } |
1399 bool hidden(const Node& n) const { return Parent::hidden(n); } |
1335 |
1400 |
1336 /// \brief Returns true if \c e is hidden. |
1401 /// \brief Returns \c true if the given edge is hidden. |
1337 /// |
1402 /// |
1338 /// Returns true if \c e is hidden. |
1403 /// This function returns \c true if the given edge is hidden. |
1339 /// |
|
1340 bool hidden(const Edge& e) const { return Parent::hidden(e); } |
1404 bool hidden(const Edge& e) const { return Parent::hidden(e); } |
1341 }; |
1405 }; |
1342 |
1406 |
1343 /// \brief Just gives back a subgraph |
1407 /// \brief Returns a read-only SubGraph adaptor |
1344 /// |
1408 /// |
1345 /// Just gives back a subgraph |
1409 /// This function just returns a read-only \ref SubGraph adaptor. |
|
1410 /// \ingroup graph_adaptors |
|
1411 /// \relates SubGraph |
1346 template<typename Graph, typename NodeFilterMap, typename ArcFilterMap> |
1412 template<typename Graph, typename NodeFilterMap, typename ArcFilterMap> |
1347 SubGraph<const Graph, NodeFilterMap, ArcFilterMap> |
1413 SubGraph<const Graph, NodeFilterMap, ArcFilterMap> |
1348 subGraph(const Graph& graph, NodeFilterMap& nfm, ArcFilterMap& efm) { |
1414 subGraph(const Graph& graph, NodeFilterMap& nfm, ArcFilterMap& efm) { |
1349 return SubGraph<const Graph, NodeFilterMap, ArcFilterMap>(graph, nfm, efm); |
1415 return SubGraph<const Graph, NodeFilterMap, ArcFilterMap>(graph, nfm, efm); |
1350 } |
1416 } |
1371 const NodeFilterMap& nfm, const ArcFilterMap& efm) { |
1437 const NodeFilterMap& nfm, const ArcFilterMap& efm) { |
1372 return SubGraph<const Graph, const NodeFilterMap, const ArcFilterMap> |
1438 return SubGraph<const Graph, const NodeFilterMap, const ArcFilterMap> |
1373 (graph, nfm, efm); |
1439 (graph, nfm, efm); |
1374 } |
1440 } |
1375 |
1441 |
|
1442 |
1376 /// \ingroup graph_adaptors |
1443 /// \ingroup graph_adaptors |
1377 /// |
1444 /// |
1378 /// \brief An adaptor for hiding nodes from a digraph or a graph. |
1445 /// \brief Adaptor class for hiding nodes in a digraph or a graph. |
1379 /// |
1446 /// |
1380 /// FilterNodes adaptor hides nodes in a graph or a digraph. A bool |
1447 /// FilterNodes adaptor can be used for hiding nodes in a digraph or a |
1381 /// node map must be specified, which defines the filters for |
1448 /// graph. A \c bool node map must be specified, which defines the filter |
1382 /// nodes. Just the unfiltered nodes and the arcs or edges incident |
1449 /// for the nodes. Only the nodes with \c true filter value and the |
1383 /// to unfiltered nodes are shown in the subdigraph or subgraph. The |
1450 /// arcs/edges incident to nodes both with \c true filter value are shown |
1384 /// FilterNodes is conform to the \ref concepts::Digraph |
1451 /// in the subgraph. This adaptor conforms to the \ref concepts::Digraph |
1385 /// "Digraph concept" or \ref concepts::Graph "Graph concept" depending |
1452 /// "Digraph" concept or the \ref concepts::Graph "Graph" concept |
1386 /// on the \c _Digraph template parameter. If the \c _checked |
1453 /// depending on the \c _Graph template parameter. |
1387 /// parameter is true, then the arc or edges incident to filtered nodes |
1454 /// |
1388 /// are also filtered out. |
1455 /// The adapted (di)graph can also be modified through this adaptor |
1389 /// |
1456 /// by adding or removing nodes or arcs/edges, unless the \c _Graph template |
1390 /// \tparam _Digraph It must be conform to the \ref |
1457 /// parameter is set to be \c const. |
1391 /// concepts::Digraph "Digraph concept" or \ref concepts::Graph |
1458 /// |
1392 /// "Graph concept". The type can be specified to be const. |
1459 /// \tparam _Graph The type of the adapted digraph or graph. |
1393 /// \tparam _NodeFilterMap A bool valued node map of the the adapted graph. |
1460 /// It must conform to the \ref concepts::Digraph "Digraph" concept |
1394 /// \tparam _checked If the parameter is false then the arc or edge |
1461 /// or the \ref concepts::Graph "Graph" concept. |
1395 /// filtering is not checked with respect to node filter. In this |
1462 /// It can also be specified to be \c const. |
1396 /// case just isolated nodes can be filtered out from the |
1463 /// \tparam _NodeFilterMap A \c bool (or convertible) node map of the |
1397 /// graph. |
1464 /// adapted (di)graph. The default map type is |
|
1465 /// \ref concepts::Graph::NodeMap "_Graph::NodeMap<bool>". |
|
1466 /// \tparam _checked If this parameter is set to \c false then the arc/edge |
|
1467 /// filtering is not checked with respect to the node filter. In this |
|
1468 /// case only isolated nodes can be filtered out from the graph. |
|
1469 /// Otherwise, each arc/edge that is incident to a hidden node is |
|
1470 /// automatically filtered out. This is the default option. |
|
1471 /// |
|
1472 /// \note The \c Node and <tt>Arc/Edge</tt> types of this adaptor and the |
|
1473 /// adapted (di)graph are convertible to each other. |
1398 #ifdef DOXYGEN |
1474 #ifdef DOXYGEN |
1399 template<typename _Digraph, |
1475 template<typename _Graph, |
1400 typename _NodeFilterMap = typename _Digraph::template NodeMap<bool>, |
1476 typename _NodeFilterMap, |
1401 bool _checked = true> |
1477 bool _checked> |
1402 #else |
1478 #else |
1403 template<typename _Digraph, |
1479 template<typename _Digraph, |
1404 typename _NodeFilterMap = typename _Digraph::template NodeMap<bool>, |
1480 typename _NodeFilterMap = typename _Digraph::template NodeMap<bool>, |
1405 bool _checked = true, |
1481 bool _checked = true, |
1406 typename Enable = void> |
1482 typename Enable = void> |
1428 |
1504 |
1429 public: |
1505 public: |
1430 |
1506 |
1431 /// \brief Constructor |
1507 /// \brief Constructor |
1432 /// |
1508 /// |
1433 /// Creates an adaptor for the given digraph or graph with |
1509 /// Creates a subgraph for the given digraph or graph with the |
1434 /// given node filter map. |
1510 /// given node filter map. |
1435 FilterNodes(Digraph& _digraph, NodeFilterMap& node_filter) : |
1511 #ifdef DOXYGEN |
|
1512 FilterNodes(_Graph& graph, _NodeFilterMap& node_filter) : |
|
1513 #else |
|
1514 FilterNodes(Digraph& graph, NodeFilterMap& node_filter) : |
|
1515 #endif |
1436 Parent(), const_true_map(true) { |
1516 Parent(), const_true_map(true) { |
1437 Parent::setDigraph(_digraph); |
1517 Parent::setDigraph(graph); |
1438 Parent::setNodeFilterMap(node_filter); |
1518 Parent::setNodeFilterMap(node_filter); |
1439 Parent::setArcFilterMap(const_true_map); |
1519 Parent::setArcFilterMap(const_true_map); |
1440 } |
1520 } |
1441 |
1521 |
1442 /// \brief Hides the node of the graph |
1522 /// \brief Hides the given node |
1443 /// |
1523 /// |
1444 /// This function hides \c n in the digraph or graph, i.e. the iteration |
1524 /// This function hides the given node in the subgraph, |
1445 /// jumps over it. This is done by simply setting the value of \c n |
1525 /// i.e. the iteration jumps over it. |
1446 /// to be false in the corresponding node map. |
1526 /// It is done by simply setting the assigned value of \c n |
|
1527 /// to be \c false in the node filter map. |
1447 void hide(const Node& n) const { Parent::hide(n); } |
1528 void hide(const Node& n) const { Parent::hide(n); } |
1448 |
1529 |
1449 /// \brief Unhides the node of the graph |
1530 /// \brief Shows the given node |
1450 /// |
1531 /// |
1451 /// The value of \c n is set to be true in the node-map which stores |
1532 /// This function shows the given node in the subgraph. |
1452 /// hide information. If \c n was hidden previuosly, then it is shown |
1533 /// It is done by simply setting the assigned value of \c n |
1453 /// again |
1534 /// to be \c true in the node filter map. |
1454 void unHide(const Node& n) const { Parent::unHide(n); } |
1535 void unHide(const Node& n) const { Parent::unHide(n); } |
1455 |
1536 |
1456 /// \brief Returns true if \c n is hidden. |
1537 /// \brief Returns \c true if the given node is hidden. |
1457 /// |
1538 /// |
1458 /// Returns true if \c n is hidden. |
1539 /// This function returns \c true if the given node is hidden. |
1459 /// |
|
1460 bool hidden(const Node& n) const { return Parent::hidden(n); } |
1540 bool hidden(const Node& n) const { return Parent::hidden(n); } |
1461 |
1541 |
1462 }; |
1542 }; |
1463 |
1543 |
1464 template<typename _Graph, typename _NodeFilterMap, bool _checked> |
1544 template<typename _Graph, typename _NodeFilterMap, bool _checked> |
1511 return FilterNodes<const Digraph, const NodeFilterMap>(digraph, nfm); |
1593 return FilterNodes<const Digraph, const NodeFilterMap>(digraph, nfm); |
1512 } |
1594 } |
1513 |
1595 |
1514 /// \ingroup graph_adaptors |
1596 /// \ingroup graph_adaptors |
1515 /// |
1597 /// |
1516 /// \brief An adaptor for hiding arcs from a digraph. |
1598 /// \brief Adaptor class for hiding arcs in a digraph. |
1517 /// |
1599 /// |
1518 /// FilterArcs adaptor hides arcs in a digraph. A bool arc map must |
1600 /// FilterArcs adaptor can be used for hiding arcs in a digraph. |
1519 /// be specified, which defines the filters for arcs. Just the |
1601 /// A \c bool arc map must be specified, which defines the filter for |
1520 /// unfiltered arcs are shown in the subdigraph. The FilterArcs is |
1602 /// the arcs. Only the arcs with \c true filter value are shown in the |
1521 /// conform to the \ref concepts::Digraph "Digraph concept". |
1603 /// subdigraph. This adaptor conforms to the \ref concepts::Digraph |
1522 /// |
1604 /// "Digraph" concept. |
1523 /// \tparam _Digraph It must be conform to the \ref concepts::Digraph |
1605 /// |
1524 /// "Digraph concept". The type can be specified to be const. |
1606 /// The adapted digraph can also be modified through this adaptor |
1525 /// \tparam _ArcFilterMap A bool valued arc map of the the adapted |
1607 /// by adding or removing nodes or arcs, unless the \c _Digraph template |
1526 /// graph. |
1608 /// parameter is set to be \c const. |
1527 template<typename _Digraph, typename _ArcFilterMap> |
1609 /// |
|
1610 /// \tparam _Digraph The type of the adapted digraph. |
|
1611 /// It must conform to the \ref concepts::Digraph "Digraph" concept. |
|
1612 /// It can also be specified to be \c const. |
|
1613 /// \tparam _ArcFilterMap A \c bool (or convertible) arc map of the |
|
1614 /// adapted digraph. The default map type is |
|
1615 /// \ref concepts::Digraph::ArcMap "_Digraph::ArcMap<bool>". |
|
1616 /// |
|
1617 /// \note The \c Node and \c Arc types of this adaptor and the adapted |
|
1618 /// digraph are convertible to each other. |
|
1619 #ifdef DOXYGEN |
|
1620 template<typename _Digraph, |
|
1621 typename _ArcFilterMap> |
|
1622 #else |
|
1623 template<typename _Digraph, |
|
1624 typename _ArcFilterMap = typename _Digraph::template ArcMap<bool> > |
|
1625 #endif |
1528 class FilterArcs : |
1626 class FilterArcs : |
1529 public SubDigraph<_Digraph, ConstMap<typename _Digraph::Node, bool>, |
1627 public SubDigraph<_Digraph, ConstMap<typename _Digraph::Node, bool>, |
1530 _ArcFilterMap, false> { |
1628 _ArcFilterMap, false> { |
1531 public: |
1629 public: |
|
1630 |
1532 typedef _Digraph Digraph; |
1631 typedef _Digraph Digraph; |
1533 typedef _ArcFilterMap ArcFilterMap; |
1632 typedef _ArcFilterMap ArcFilterMap; |
1534 |
1633 |
1535 typedef SubDigraph<Digraph, ConstMap<typename Digraph::Node, bool>, |
1634 typedef SubDigraph<Digraph, ConstMap<typename Digraph::Node, bool>, |
1536 ArcFilterMap, false> Parent; |
1635 ArcFilterMap, false> Parent; |
1546 |
1645 |
1547 public: |
1646 public: |
1548 |
1647 |
1549 /// \brief Constructor |
1648 /// \brief Constructor |
1550 /// |
1649 /// |
1551 /// Creates a FilterArcs adaptor for the given graph with |
1650 /// Creates a subdigraph for the given digraph with the given arc |
1552 /// given arc map filter. |
1651 /// filter map. |
1553 FilterArcs(Digraph& digraph, ArcFilterMap& arc_filter) |
1652 FilterArcs(Digraph& digraph, ArcFilterMap& arc_filter) |
1554 : Parent(), const_true_map(true) { |
1653 : Parent(), const_true_map(true) { |
1555 Parent::setDigraph(digraph); |
1654 Parent::setDigraph(digraph); |
1556 Parent::setNodeFilterMap(const_true_map); |
1655 Parent::setNodeFilterMap(const_true_map); |
1557 Parent::setArcFilterMap(arc_filter); |
1656 Parent::setArcFilterMap(arc_filter); |
1558 } |
1657 } |
1559 |
1658 |
1560 /// \brief Hides the arc of the graph |
1659 /// \brief Hides the given arc |
1561 /// |
1660 /// |
1562 /// This function hides \c a in the graph, i.e. the iteration |
1661 /// This function hides the given arc in the subdigraph, |
1563 /// jumps over it. This is done by simply setting the value of \c a |
1662 /// i.e. the iteration jumps over it. |
1564 /// to be false in the corresponding arc map. |
1663 /// It is done by simply setting the assigned value of \c a |
|
1664 /// to be \c false in the arc filter map. |
1565 void hide(const Arc& a) const { Parent::hide(a); } |
1665 void hide(const Arc& a) const { Parent::hide(a); } |
1566 |
1666 |
1567 /// \brief Unhides the arc of the graph |
1667 /// \brief Shows the given arc |
1568 /// |
1668 /// |
1569 /// The value of \c a is set to be true in the arc-map which stores |
1669 /// This function shows the given arc in the subdigraph. |
1570 /// hide information. If \c a was hidden previuosly, then it is shown |
1670 /// It is done by simply setting the assigned value of \c a |
1571 /// again |
1671 /// to be \c true in the arc filter map. |
1572 void unHide(const Arc& a) const { Parent::unHide(a); } |
1672 void unHide(const Arc& a) const { Parent::unHide(a); } |
1573 |
1673 |
1574 /// \brief Returns true if \c a is hidden. |
1674 /// \brief Returns \c true if the given arc is hidden. |
1575 /// |
1675 /// |
1576 /// Returns true if \c a is hidden. |
1676 /// This function returns \c true if the given arc is hidden. |
1577 /// |
|
1578 bool hidden(const Arc& a) const { return Parent::hidden(a); } |
1677 bool hidden(const Arc& a) const { return Parent::hidden(a); } |
1579 |
1678 |
1580 }; |
1679 }; |
1581 |
1680 |
1582 /// \brief Just gives back an FilterArcs adaptor |
1681 /// \brief Returns a read-only FilterArcs adaptor |
1583 /// |
1682 /// |
1584 /// Just gives back an FilterArcs adaptor |
1683 /// This function just returns a read-only \ref FilterArcs adaptor. |
|
1684 /// \ingroup graph_adaptors |
|
1685 /// \relates FilterArcs |
1585 template<typename Digraph, typename ArcFilterMap> |
1686 template<typename Digraph, typename ArcFilterMap> |
1586 FilterArcs<const Digraph, ArcFilterMap> |
1687 FilterArcs<const Digraph, ArcFilterMap> |
1587 filterArcs(const Digraph& digraph, ArcFilterMap& afm) { |
1688 filterArcs(const Digraph& digraph, ArcFilterMap& afm) { |
1588 return FilterArcs<const Digraph, ArcFilterMap>(digraph, afm); |
1689 return FilterArcs<const Digraph, ArcFilterMap>(digraph, afm); |
1589 } |
1690 } |
1594 return FilterArcs<const Digraph, const ArcFilterMap>(digraph, afm); |
1695 return FilterArcs<const Digraph, const ArcFilterMap>(digraph, afm); |
1595 } |
1696 } |
1596 |
1697 |
1597 /// \ingroup graph_adaptors |
1698 /// \ingroup graph_adaptors |
1598 /// |
1699 /// |
1599 /// \brief An adaptor for hiding edges from a graph. |
1700 /// \brief Adaptor class for hiding edges in a graph. |
1600 /// |
1701 /// |
1601 /// FilterEdges adaptor hides edges in a digraph. A bool edge map must |
1702 /// FilterEdges adaptor can be used for hiding edges in a graph. |
1602 /// be specified, which defines the filters for edges. Just the |
1703 /// A \c bool edge map must be specified, which defines the filter for |
1603 /// unfiltered edges are shown in the subdigraph. The FilterEdges is |
1704 /// the edges. Only the edges with \c true filter value are shown in the |
1604 /// conform to the \ref concepts::Graph "Graph concept". |
1705 /// subgraph. This adaptor conforms to the \ref concepts::Graph |
1605 /// |
1706 /// "Graph" concept. |
1606 /// \tparam _Graph It must be conform to the \ref concepts::Graph |
1707 /// |
1607 /// "Graph concept". The type can be specified to be const. |
1708 /// The adapted graph can also be modified through this adaptor |
1608 /// \tparam _EdgeFilterMap A bool valued edge map of the the adapted |
1709 /// by adding or removing nodes or edges, unless the \c _Graph template |
1609 /// graph. |
1710 /// parameter is set to be \c const. |
1610 template<typename _Graph, typename _EdgeFilterMap> |
1711 /// |
|
1712 /// \tparam _Graph The type of the adapted graph. |
|
1713 /// It must conform to the \ref concepts::Graph "Graph" concept. |
|
1714 /// It can also be specified to be \c const. |
|
1715 /// \tparam _EdgeFilterMap A \c bool (or convertible) edge map of the |
|
1716 /// adapted graph. The default map type is |
|
1717 /// \ref concepts::Graph::EdgeMap "_Graph::EdgeMap<bool>". |
|
1718 /// |
|
1719 /// \note The \c Node, \c Edge and \c Arc types of this adaptor and the |
|
1720 /// adapted graph are convertible to each other. |
|
1721 #ifdef DOXYGEN |
|
1722 template<typename _Graph, |
|
1723 typename _EdgeFilterMap> |
|
1724 #else |
|
1725 template<typename _Graph, |
|
1726 typename _EdgeFilterMap = typename _Graph::template EdgeMap<bool> > |
|
1727 #endif |
1611 class FilterEdges : |
1728 class FilterEdges : |
1612 public SubGraph<_Graph, ConstMap<typename _Graph::Node,bool>, |
1729 public SubGraph<_Graph, ConstMap<typename _Graph::Node,bool>, |
1613 _EdgeFilterMap, false> { |
1730 _EdgeFilterMap, false> { |
1614 public: |
1731 public: |
1615 typedef _Graph Graph; |
1732 typedef _Graph Graph; |
1626 |
1743 |
1627 public: |
1744 public: |
1628 |
1745 |
1629 /// \brief Constructor |
1746 /// \brief Constructor |
1630 /// |
1747 /// |
1631 /// Creates a FilterEdges adaptor for the given graph with |
1748 /// Creates a subgraph for the given graph with the given edge |
1632 /// given edge map filters. |
1749 /// filter map. |
1633 FilterEdges(Graph& _graph, EdgeFilterMap& edge_filter_map) : |
1750 FilterEdges(Graph& graph, EdgeFilterMap& edge_filter_map) : |
1634 Parent(), const_true_map(true) { |
1751 Parent(), const_true_map(true) { |
1635 Parent::setGraph(_graph); |
1752 Parent::setGraph(graph); |
1636 Parent::setNodeFilterMap(const_true_map); |
1753 Parent::setNodeFilterMap(const_true_map); |
1637 Parent::setEdgeFilterMap(edge_filter_map); |
1754 Parent::setEdgeFilterMap(edge_filter_map); |
1638 } |
1755 } |
1639 |
1756 |
1640 /// \brief Hides the edge of the graph |
1757 /// \brief Hides the given edge |
1641 /// |
1758 /// |
1642 /// This function hides \c e in the graph, i.e. the iteration |
1759 /// This function hides the given edge in the subgraph, |
1643 /// jumps over it. This is done by simply setting the value of \c e |
1760 /// i.e. the iteration jumps over it. |
1644 /// to be false in the corresponding edge-map. |
1761 /// It is done by simply setting the assigned value of \c e |
|
1762 /// to be \c false in the edge filter map. |
1645 void hide(const Edge& e) const { Parent::hide(e); } |
1763 void hide(const Edge& e) const { Parent::hide(e); } |
1646 |
1764 |
1647 /// \brief Unhides the edge of the graph |
1765 /// \brief Shows the given edge |
1648 /// |
1766 /// |
1649 /// The value of \c e is set to be true in the edge-map which stores |
1767 /// This function shows the given edge in the subgraph. |
1650 /// hide information. If \c e was hidden previuosly, then it is shown |
1768 /// It is done by simply setting the assigned value of \c e |
1651 /// again |
1769 /// to be \c true in the edge filter map. |
1652 void unHide(const Edge& e) const { Parent::unHide(e); } |
1770 void unHide(const Edge& e) const { Parent::unHide(e); } |
1653 |
1771 |
1654 /// \brief Returns true if \c e is hidden. |
1772 /// \brief Returns \c true if the given edge is hidden. |
1655 /// |
1773 /// |
1656 /// Returns true if \c e is hidden. |
1774 /// This function returns \c true if the given edge is hidden. |
1657 /// |
|
1658 bool hidden(const Edge& e) const { return Parent::hidden(e); } |
1775 bool hidden(const Edge& e) const { return Parent::hidden(e); } |
1659 |
1776 |
1660 }; |
1777 }; |
1661 |
1778 |
1662 /// \brief Just gives back a FilterEdges adaptor |
1779 /// \brief Returns a read-only FilterEdges adaptor |
1663 /// |
1780 /// |
1664 /// Just gives back a FilterEdges adaptor |
1781 /// This function just returns a read-only \ref FilterEdges adaptor. |
|
1782 /// \ingroup graph_adaptors |
|
1783 /// \relates FilterEdges |
1665 template<typename Graph, typename EdgeFilterMap> |
1784 template<typename Graph, typename EdgeFilterMap> |
1666 FilterEdges<const Graph, EdgeFilterMap> |
1785 FilterEdges<const Graph, EdgeFilterMap> |
1667 filterEdges(const Graph& graph, EdgeFilterMap& efm) { |
1786 filterEdges(const Graph& graph, EdgeFilterMap& efm) { |
1668 return FilterEdges<const Graph, EdgeFilterMap>(graph, efm); |
1787 return FilterEdges<const Graph, EdgeFilterMap>(graph, efm); |
1669 } |
1788 } |
2088 Undirector() { } |
2217 Undirector() { } |
2089 public: |
2218 public: |
2090 |
2219 |
2091 /// \brief Constructor |
2220 /// \brief Constructor |
2092 /// |
2221 /// |
2093 /// Creates a undirected graph from the given digraph |
2222 /// Creates an undirected graph from the given digraph. |
2094 Undirector(_Digraph& digraph) { |
2223 Undirector(_Digraph& digraph) { |
2095 setDigraph(digraph); |
2224 setDigraph(digraph); |
2096 } |
2225 } |
2097 |
2226 |
2098 /// \brief ArcMap combined from two original ArcMap |
2227 /// \brief Arc map combined from two original arc maps |
2099 /// |
2228 /// |
2100 /// This class adapts two original digraph ArcMap to |
2229 /// This map adaptor class adapts two arc maps of the underlying |
2101 /// get an arc map on the undirected graph. |
2230 /// digraph to get an arc map of the undirected graph. |
|
2231 /// Its value type is inherited from the first arc map type |
|
2232 /// (\c %ForwardMap). |
2102 template <typename _ForwardMap, typename _BackwardMap> |
2233 template <typename _ForwardMap, typename _BackwardMap> |
2103 class CombinedArcMap { |
2234 class CombinedArcMap { |
2104 public: |
2235 public: |
2105 |
2236 |
2106 typedef _ForwardMap ForwardMap; |
2237 typedef _ForwardMap ForwardMap; |
2107 typedef _BackwardMap BackwardMap; |
2238 typedef _BackwardMap BackwardMap; |
2108 |
2239 |
2109 typedef typename MapTraits<ForwardMap>::ReferenceMapTag ReferenceMapTag; |
2240 typedef typename MapTraits<ForwardMap>::ReferenceMapTag ReferenceMapTag; |
2110 |
2241 |
|
2242 /// The key type of the map |
|
2243 typedef typename Parent::Arc Key; |
|
2244 /// The value type of the map |
2111 typedef typename ForwardMap::Value Value; |
2245 typedef typename ForwardMap::Value Value; |
2112 typedef typename Parent::Arc Key; |
|
2113 |
2246 |
2114 typedef typename MapTraits<ForwardMap>::ReturnValue ReturnValue; |
2247 typedef typename MapTraits<ForwardMap>::ReturnValue ReturnValue; |
2115 typedef typename MapTraits<ForwardMap>::ConstReturnValue ConstReturnValue; |
2248 typedef typename MapTraits<ForwardMap>::ConstReturnValue ConstReturnValue; |
2116 typedef typename MapTraits<ForwardMap>::ReturnValue Reference; |
2249 typedef typename MapTraits<ForwardMap>::ReturnValue Reference; |
2117 typedef typename MapTraits<ForwardMap>::ConstReturnValue ConstReference; |
2250 typedef typename MapTraits<ForwardMap>::ConstReturnValue ConstReference; |
2118 |
2251 |
2119 /// \brief Constructor |
|
2120 /// |
|
2121 /// Constructor |
2252 /// Constructor |
2122 CombinedArcMap(ForwardMap& forward, BackwardMap& backward) |
2253 CombinedArcMap(ForwardMap& forward, BackwardMap& backward) |
2123 : _forward(&forward), _backward(&backward) {} |
2254 : _forward(&forward), _backward(&backward) {} |
2124 |
2255 |
2125 |
2256 /// Sets the value associated with the given key. |
2126 /// \brief Sets the value associated with a key. |
|
2127 /// |
|
2128 /// Sets the value associated with a key. |
|
2129 void set(const Key& e, const Value& a) { |
2257 void set(const Key& e, const Value& a) { |
2130 if (Parent::direction(e)) { |
2258 if (Parent::direction(e)) { |
2131 _forward->set(e, a); |
2259 _forward->set(e, a); |
2132 } else { |
2260 } else { |
2133 _backward->set(e, a); |
2261 _backward->set(e, a); |
2134 } |
2262 } |
2135 } |
2263 } |
2136 |
2264 |
2137 /// \brief Returns the value associated with a key. |
2265 /// Returns the value associated with the given key. |
2138 /// |
|
2139 /// Returns the value associated with a key. |
|
2140 ConstReturnValue operator[](const Key& e) const { |
2266 ConstReturnValue operator[](const Key& e) const { |
2141 if (Parent::direction(e)) { |
2267 if (Parent::direction(e)) { |
2142 return (*_forward)[e]; |
2268 return (*_forward)[e]; |
2143 } else { |
2269 } else { |
2144 return (*_backward)[e]; |
2270 return (*_backward)[e]; |
2145 } |
2271 } |
2146 } |
2272 } |
2147 |
2273 |
2148 /// \brief Returns the value associated with a key. |
2274 /// Returns a reference to the value associated with the given key. |
2149 /// |
|
2150 /// Returns the value associated with a key. |
|
2151 ReturnValue operator[](const Key& e) { |
2275 ReturnValue operator[](const Key& e) { |
2152 if (Parent::direction(e)) { |
2276 if (Parent::direction(e)) { |
2153 return (*_forward)[e]; |
2277 return (*_forward)[e]; |
2154 } else { |
2278 } else { |
2155 return (*_backward)[e]; |
2279 return (*_backward)[e]; |
2362 |
2489 |
2363 }; |
2490 }; |
2364 |
2491 |
2365 /// \ingroup graph_adaptors |
2492 /// \ingroup graph_adaptors |
2366 /// |
2493 /// |
2367 /// \brief Orients the edges of the graph to get a digraph |
2494 /// \brief Adaptor class for orienting the edges of a graph to get a digraph |
2368 /// |
2495 /// |
2369 /// This adaptor orients each edge in the undirected graph. The |
2496 /// Orienter adaptor can be used for orienting the edges of a graph to |
2370 /// direction of the arcs stored in an edge node map. The arcs can |
2497 /// get a digraph. A \c bool edge map of the underlying graph must be |
2371 /// be easily reverted by the \c reverseArc() member function in the |
2498 /// specified, which define the direction of the arcs in the adaptor. |
2372 /// adaptor. The Orienter adaptor is conform to the \ref |
2499 /// The arcs can be easily reversed by the \c reverseArc() member function |
2373 /// concepts::Digraph "Digraph concept". |
2500 /// of the adaptor. |
2374 /// |
2501 /// This class conforms to the \ref concepts::Digraph "Digraph" concept. |
2375 /// \tparam _Graph It must be conform to the \ref concepts::Graph |
2502 /// |
2376 /// "Graph concept". The type can be specified to be const. |
2503 /// The adapted graph can also be modified through this adaptor |
2377 /// \tparam _DirectionMap A bool valued edge map of the the adapted |
2504 /// by adding or removing nodes or arcs, unless the \c _Graph template |
2378 /// graph. |
2505 /// parameter is set to be \c const. |
2379 /// |
2506 /// |
2380 /// \sa orienter |
2507 /// \tparam _Graph The type of the adapted graph. |
|
2508 /// It must conform to the \ref concepts::Graph "Graph" concept. |
|
2509 /// It can also be specified to be \c const. |
|
2510 /// \tparam _DirectionMap A \c bool (or convertible) edge map of the |
|
2511 /// adapted graph. The default map type is |
|
2512 /// \ref concepts::Graph::EdgeMap "_Graph::EdgeMap<bool>". |
|
2513 /// |
|
2514 /// \note The \c Node type of this adaptor and the adapted graph are |
|
2515 /// convertible to each other, moreover the \c Arc type of the adaptor |
|
2516 /// and the \c Edge type of the adapted graph are also convertible to |
|
2517 /// each other. |
|
2518 #ifdef DOXYGEN |
2381 template<typename _Graph, |
2519 template<typename _Graph, |
2382 typename DirectionMap = typename _Graph::template EdgeMap<bool> > |
2520 typename _DirectionMap> |
|
2521 #else |
|
2522 template<typename _Graph, |
|
2523 typename _DirectionMap = typename _Graph::template EdgeMap<bool> > |
|
2524 #endif |
2383 class Orienter : |
2525 class Orienter : |
2384 public DigraphAdaptorExtender<OrienterBase<_Graph, DirectionMap> > { |
2526 public DigraphAdaptorExtender<OrienterBase<_Graph, _DirectionMap> > { |
2385 public: |
2527 public: |
|
2528 |
|
2529 /// The type of the adapted graph. |
2386 typedef _Graph Graph; |
2530 typedef _Graph Graph; |
|
2531 /// The type of the direction edge map. |
|
2532 typedef _DirectionMap DirectionMap; |
|
2533 |
2387 typedef DigraphAdaptorExtender< |
2534 typedef DigraphAdaptorExtender< |
2388 OrienterBase<_Graph, DirectionMap> > Parent; |
2535 OrienterBase<_Graph, _DirectionMap> > Parent; |
2389 typedef typename Parent::Arc Arc; |
2536 typedef typename Parent::Arc Arc; |
2390 protected: |
2537 protected: |
2391 Orienter() { } |
2538 Orienter() { } |
2392 public: |
2539 public: |
2393 |
2540 |
2394 /// \brief Constructor of the adaptor |
2541 /// \brief Constructor |
2395 /// |
2542 /// |
2396 /// Constructor of the adaptor |
2543 /// Constructor of the adaptor. |
2397 Orienter(Graph& graph, DirectionMap& direction) { |
2544 Orienter(Graph& graph, DirectionMap& direction) { |
2398 setGraph(graph); |
2545 setGraph(graph); |
2399 setDirectionMap(direction); |
2546 setDirectionMap(direction); |
2400 } |
2547 } |
2401 |
2548 |
2402 /// \brief Reverse arc |
2549 /// \brief Reverses the given arc |
2403 /// |
2550 /// |
2404 /// It reverse the given arc. It simply negate the direction in the map. |
2551 /// This function reverses the given arc. |
|
2552 /// It is done by simply negate the assigned value of \c a |
|
2553 /// in the direction map. |
2405 void reverseArc(const Arc& a) { |
2554 void reverseArc(const Arc& a) { |
2406 Parent::reverseArc(a); |
2555 Parent::reverseArc(a); |
2407 } |
2556 } |
2408 }; |
2557 }; |
2409 |
2558 |
2410 /// \brief Just gives back a Orienter |
2559 /// \brief Returns a read-only Orienter adaptor |
2411 /// |
2560 /// |
2412 /// Just gives back a Orienter |
2561 /// This function just returns a read-only \ref Orienter adaptor. |
|
2562 /// \ingroup graph_adaptors |
|
2563 /// \relates Orienter |
2413 template<typename Graph, typename DirectionMap> |
2564 template<typename Graph, typename DirectionMap> |
2414 Orienter<const Graph, DirectionMap> |
2565 Orienter<const Graph, DirectionMap> |
2415 orienter(const Graph& graph, DirectionMap& dm) { |
2566 orienter(const Graph& graph, DirectionMap& dm) { |
2416 return Orienter<const Graph, DirectionMap>(graph, dm); |
2567 return Orienter<const Graph, DirectionMap>(graph, dm); |
2417 } |
2568 } |
2489 |
2640 |
2490 } |
2641 } |
2491 |
2642 |
2492 /// \ingroup graph_adaptors |
2643 /// \ingroup graph_adaptors |
2493 /// |
2644 /// |
2494 /// \brief An adaptor for composing the residual graph for directed |
2645 /// \brief Adaptor class for composing the residual digraph for directed |
2495 /// flow and circulation problems. |
2646 /// flow and circulation problems. |
2496 /// |
2647 /// |
2497 /// An adaptor for composing the residual graph for directed flow and |
2648 /// Residual can be used for composing the \e residual digraph for directed |
2498 /// circulation problems. Let \f$ G=(V, A) \f$ be a directed graph |
2649 /// flow and circulation problems. Let \f$ G=(V, A) \f$ be a directed graph |
2499 /// and let \f$ F \f$ be a number type. Let moreover \f$ f,c:A\to F \f$, |
2650 /// and let \f$ F \f$ be a number type. Let \f$ flow, cap: A\to F \f$ be |
2500 /// be functions on the arc-set. |
2651 /// functions on the arcs. |
2501 /// |
2652 /// This adaptor implements a digraph structure with node set \f$ V \f$ |
2502 /// Then Residual implements the digraph structure with |
2653 /// and arc set \f$ A_{forward}\cup A_{backward} \f$, |
2503 /// node-set \f$ V \f$ and arc-set \f$ A_{forward}\cup A_{backward} \f$, |
2654 /// where \f$ A_{forward}=\{uv : uv\in A, flow(uv)<cap(uv)\} \f$ and |
2504 /// where \f$ A_{forward}=\{uv : uv\in A, f(uv)<c(uv)\} \f$ and |
2655 /// \f$ A_{backward}=\{vu : uv\in A, flow(uv)>0\} \f$, i.e. the so |
2505 /// \f$ A_{backward}=\{vu : uv\in A, f(uv)>0\} \f$, i.e. the so |
2656 /// called residual digraph. |
2506 /// called residual graph. When we take the union |
2657 /// When the union \f$ A_{forward}\cup A_{backward} \f$ is taken, |
2507 /// \f$ A_{forward}\cup A_{backward} \f$, multiplicities are counted, |
2658 /// multiplicities are counted, i.e. the adaptor has exactly |
2508 /// i.e. if an arc is in both \f$ A_{forward} \f$ and |
2659 /// \f$ |A_{forward}| + |A_{backward}|\f$ arcs (it may have parallel |
2509 /// \f$ A_{backward} \f$, then in the adaptor it appears in both |
2660 /// arcs). |
2510 /// orientation. |
2661 /// This class conforms to the \ref concepts::Digraph "Digraph" concept. |
2511 /// |
2662 /// |
2512 /// \tparam _Digraph It must be conform to the \ref concepts::Digraph |
2663 /// \tparam _Digraph The type of the adapted digraph. |
2513 /// "Digraph concept". The type is implicitly const. |
2664 /// It must conform to the \ref concepts::Digraph "Digraph" concept. |
2514 /// \tparam _CapacityMap An arc map of some numeric type, it defines |
2665 /// It is implicitly \c const. |
2515 /// the capacities in the flow problem. The map is implicitly const. |
2666 /// \tparam _CapacityMap An arc map of some numerical type, which defines |
2516 /// \tparam _FlowMap An arc map of some numeric type, it defines |
2667 /// the capacities in the flow problem. It is implicitly \c const. |
2517 /// the capacities in the flow problem. |
2668 /// The default map type is |
2518 /// \tparam _Tolerance Handler for inexact computation. |
2669 /// \ref concepts::Digraph::ArcMap "_Digraph::ArcMap<int>". |
|
2670 /// \tparam _FlowMap An arc map of some numerical type, which defines |
|
2671 /// the flow values in the flow problem. |
|
2672 /// The default map type is \c _CapacityMap. |
|
2673 /// \tparam _Tolerance Tolerance type for handling inexact computation. |
|
2674 /// The default tolerance type depends on the value type of the |
|
2675 /// capacity map. |
|
2676 /// |
|
2677 /// \note This adaptor is implemented using Undirector and FilterArcs |
|
2678 /// adaptors. |
|
2679 /// |
|
2680 /// \note The \c Node type of this adaptor and the adapted digraph are |
|
2681 /// convertible to each other, moreover the \c Arc type of the adaptor |
|
2682 /// is convertible to the \c Arc type of the adapted digraph. |
|
2683 #ifdef DOXYGEN |
|
2684 template<typename _Digraph, |
|
2685 typename _CapacityMap, |
|
2686 typename _FlowMap, |
|
2687 typename _Tolerance> |
|
2688 class Residual |
|
2689 #else |
2519 template<typename _Digraph, |
2690 template<typename _Digraph, |
2520 typename _CapacityMap = typename _Digraph::template ArcMap<int>, |
2691 typename _CapacityMap = typename _Digraph::template ArcMap<int>, |
2521 typename _FlowMap = _CapacityMap, |
2692 typename _FlowMap = _CapacityMap, |
2522 typename _Tolerance = Tolerance<typename _CapacityMap::Value> > |
2693 typename _Tolerance = Tolerance<typename _CapacityMap::Value> > |
2523 class Residual : |
2694 class Residual : |
2579 Parent::setArcFilterMap(_arc_filter); |
2754 Parent::setArcFilterMap(_arc_filter); |
2580 } |
2755 } |
2581 |
2756 |
2582 typedef typename Parent::Arc Arc; |
2757 typedef typename Parent::Arc Arc; |
2583 |
2758 |
2584 /// \brief Gives back the residual capacity of the arc. |
2759 /// \brief Returns the residual capacity of the given arc. |
2585 /// |
2760 /// |
2586 /// Gives back the residual capacity of the arc. |
2761 /// Returns the residual capacity of the given arc. |
2587 Value residualCapacity(const Arc& a) const { |
2762 Value residualCapacity(const Arc& a) const { |
2588 if (Undirected::direction(a)) { |
2763 if (Undirected::direction(a)) { |
2589 return (*_capacity)[a] - (*_flow)[a]; |
2764 return (*_capacity)[a] - (*_flow)[a]; |
2590 } else { |
2765 } else { |
2591 return (*_flow)[a]; |
2766 return (*_flow)[a]; |
2592 } |
2767 } |
2593 } |
2768 } |
2594 |
2769 |
2595 /// \brief Augment on the given arc in the residual graph. |
2770 /// \brief Augment on the given arc in the residual digraph. |
2596 /// |
2771 /// |
2597 /// Augment on the given arc in the residual graph. It increase |
2772 /// Augment on the given arc in the residual digraph. It increases |
2598 /// or decrease the flow on the original arc depend on the direction |
2773 /// or decreases the flow value on the original arc according to the |
2599 /// of the residual arc. |
2774 /// direction of the residual arc. |
2600 void augment(const Arc& a, const Value& v) const { |
2775 void augment(const Arc& a, const Value& v) const { |
2601 if (Undirected::direction(a)) { |
2776 if (Undirected::direction(a)) { |
2602 _flow->set(a, (*_flow)[a] + v); |
2777 _flow->set(a, (*_flow)[a] + v); |
2603 } else { |
2778 } else { |
2604 _flow->set(a, (*_flow)[a] - v); |
2779 _flow->set(a, (*_flow)[a] - v); |
2605 } |
2780 } |
2606 } |
2781 } |
2607 |
2782 |
2608 /// \brief Returns the direction of the arc. |
2783 /// \brief Returns \c true if the given residual arc is a forward arc. |
2609 /// |
2784 /// |
2610 /// Returns true when the arc is same oriented as the original arc. |
2785 /// Returns \c true if the given residual arc has the same orientation |
|
2786 /// as the original arc, i.e. it is a so called forward arc. |
2611 static bool forward(const Arc& a) { |
2787 static bool forward(const Arc& a) { |
2612 return Undirected::direction(a); |
2788 return Undirected::direction(a); |
2613 } |
2789 } |
2614 |
2790 |
2615 /// \brief Returns the direction of the arc. |
2791 /// \brief Returns \c true if the given residual arc is a backward arc. |
2616 /// |
2792 /// |
2617 /// Returns true when the arc is opposite oriented as the original arc. |
2793 /// Returns \c true if the given residual arc has the opposite orientation |
|
2794 /// than the original arc, i.e. it is a so called backward arc. |
2618 static bool backward(const Arc& a) { |
2795 static bool backward(const Arc& a) { |
2619 return !Undirected::direction(a); |
2796 return !Undirected::direction(a); |
2620 } |
2797 } |
2621 |
2798 |
2622 /// \brief Gives back the forward oriented residual arc. |
2799 /// \brief Returns the forward oriented residual arc. |
2623 /// |
2800 /// |
2624 /// Gives back the forward oriented residual arc. |
2801 /// Returns the forward oriented residual arc related to the given |
|
2802 /// arc of the underlying digraph. |
2625 static Arc forward(const typename Digraph::Arc& a) { |
2803 static Arc forward(const typename Digraph::Arc& a) { |
2626 return Undirected::direct(a, true); |
2804 return Undirected::direct(a, true); |
2627 } |
2805 } |
2628 |
2806 |
2629 /// \brief Gives back the backward oriented residual arc. |
2807 /// \brief Returns the backward oriented residual arc. |
2630 /// |
2808 /// |
2631 /// Gives back the backward oriented residual arc. |
2809 /// Returns the backward oriented residual arc related to the given |
|
2810 /// arc of the underlying digraph. |
2632 static Arc backward(const typename Digraph::Arc& a) { |
2811 static Arc backward(const typename Digraph::Arc& a) { |
2633 return Undirected::direct(a, false); |
2812 return Undirected::direct(a, false); |
2634 } |
2813 } |
2635 |
2814 |
2636 /// \brief Residual capacity map. |
2815 /// \brief Residual capacity map. |
2637 /// |
2816 /// |
2638 /// In generic residual graph the residual capacity can be obtained |
2817 /// This map adaptor class can be used for obtaining the residual |
2639 /// as a map. |
2818 /// capacities as an arc map of the residual digraph. |
|
2819 /// Its value type is inherited from the capacity map. |
2640 class ResidualCapacity { |
2820 class ResidualCapacity { |
2641 protected: |
2821 protected: |
2642 const Adaptor* _adaptor; |
2822 const Adaptor* _adaptor; |
2643 public: |
2823 public: |
2644 /// The Key type |
2824 /// The key type of the map |
2645 typedef Arc Key; |
2825 typedef Arc Key; |
2646 /// The Value type |
2826 /// The value type of the map |
2647 typedef typename _CapacityMap::Value Value; |
2827 typedef typename _CapacityMap::Value Value; |
2648 |
2828 |
2649 /// Constructor |
2829 /// Constructor |
2650 ResidualCapacity(const Adaptor& adaptor) : _adaptor(&adaptor) {} |
2830 ResidualCapacity(const Adaptor& adaptor) : _adaptor(&adaptor) {} |
2651 |
2831 |
2652 /// \e |
2832 /// Returns the value associated with the given residual arc |
2653 Value operator[](const Arc& a) const { |
2833 Value operator[](const Arc& a) const { |
2654 return _adaptor->residualCapacity(a); |
2834 return _adaptor->residualCapacity(a); |
2655 } |
2835 } |
2656 |
2836 |
2657 }; |
2837 }; |
3106 |
3286 |
3107 }; |
3287 }; |
3108 |
3288 |
3109 /// \ingroup graph_adaptors |
3289 /// \ingroup graph_adaptors |
3110 /// |
3290 /// |
3111 /// \brief Split the nodes of a directed graph |
3291 /// \brief Adaptor class for splitting the nodes of a digraph. |
3112 /// |
3292 /// |
3113 /// The SplitNodes adaptor splits each node into an in-node and an |
3293 /// SplitNodes adaptor can be used for splitting each node into an |
3114 /// out-node. Formaly, the adaptor replaces each \f$ u \f$ node in |
3294 /// \e in-node and an \e out-node in a digraph. Formaly, the adaptor |
3115 /// the digraph with two nodes(namely node \f$ u_{in} \f$ and node |
3295 /// replaces each node \f$ u \f$ in the digraph with two nodes, |
3116 /// \f$ u_{out} \f$). If there is a \f$ (v, u) \f$ arc in the |
3296 /// namely node \f$ u_{in} \f$ and node \f$ u_{out} \f$. |
3117 /// original digraph the new target of the arc will be \f$ u_{in} \f$ |
3297 /// If there is a \f$ (v, u) \f$ arc in the original digraph, then the |
3118 /// and similarly the source of the original \f$ (u, v) \f$ arc |
3298 /// new target of the arc will be \f$ u_{in} \f$ and similarly the |
3119 /// will be \f$ u_{out} \f$. The adaptor will add for each node in |
3299 /// source of each original \f$ (u, v) \f$ arc will be \f$ u_{out} \f$. |
3120 /// the original digraph an additional arc which connects |
3300 /// The adaptor adds an additional \e bind \e arc from \f$ u_{in} \f$ |
3121 /// \f$ (u_{in}, u_{out}) \f$. |
3301 /// to \f$ u_{out} \f$ for each node \f$ u \f$ of the original digraph. |
3122 /// |
3302 /// |
3123 /// The aim of this class is to run algorithm with node costs if the |
3303 /// The aim of this class is running an algorithm with respect to node |
3124 /// algorithm can use directly just arc costs. In this case we should use |
3304 /// costs or capacities if the algorithm considers only arc costs or |
3125 /// a \c SplitNodes and set the node cost of the graph to the |
3305 /// capacities directly. |
3126 /// bind arc in the adapted graph. |
3306 /// In this case you can use \c SplitNodes adaptor, and set the node |
3127 /// |
3307 /// costs/capacities of the original digraph to the \e bind \e arcs |
3128 /// \tparam _Digraph It must be conform to the \ref concepts::Digraph |
3308 /// in the adaptor. |
3129 /// "Digraph concept". The type can be specified to be const. |
3309 /// |
|
3310 /// \tparam _Digraph The type of the adapted digraph. |
|
3311 /// It must conform to the \ref concepts::Digraph "Digraph" concept. |
|
3312 /// It is implicitly \c const. |
|
3313 /// |
|
3314 /// \note The \c Node type of this adaptor is converible to the \c Node |
|
3315 /// type of the adapted digraph. |
3130 template <typename _Digraph> |
3316 template <typename _Digraph> |
3131 class SplitNodes |
3317 class SplitNodes |
3132 : public DigraphAdaptorExtender<SplitNodesBase<const _Digraph> > { |
3318 : public DigraphAdaptorExtender<SplitNodesBase<const _Digraph> > { |
3133 public: |
3319 public: |
3134 typedef _Digraph Digraph; |
3320 typedef _Digraph Digraph; |
3138 typedef typename Digraph::Arc DigraphArc; |
3324 typedef typename Digraph::Arc DigraphArc; |
3139 |
3325 |
3140 typedef typename Parent::Node Node; |
3326 typedef typename Parent::Node Node; |
3141 typedef typename Parent::Arc Arc; |
3327 typedef typename Parent::Arc Arc; |
3142 |
3328 |
3143 /// \brief Constructor of the adaptor. |
3329 /// \brief Constructor |
3144 /// |
3330 /// |
3145 /// Constructor of the adaptor. |
3331 /// Constructor of the adaptor. |
3146 SplitNodes(const Digraph& g) { |
3332 SplitNodes(const Digraph& g) { |
3147 Parent::setDigraph(g); |
3333 Parent::setDigraph(g); |
3148 } |
3334 } |
3149 |
3335 |
3150 /// \brief Returns true when the node is in-node. |
3336 /// \brief Returns \c true if the given node is an in-node. |
3151 /// |
3337 /// |
3152 /// Returns true when the node is in-node. |
3338 /// Returns \c true if the given node is an in-node. |
3153 static bool inNode(const Node& n) { |
3339 static bool inNode(const Node& n) { |
3154 return Parent::inNode(n); |
3340 return Parent::inNode(n); |
3155 } |
3341 } |
3156 |
3342 |
3157 /// \brief Returns true when the node is out-node. |
3343 /// \brief Returns \c true if the given node is an out-node. |
3158 /// |
3344 /// |
3159 /// Returns true when the node is out-node. |
3345 /// Returns \c true if the given node is an out-node. |
3160 static bool outNode(const Node& n) { |
3346 static bool outNode(const Node& n) { |
3161 return Parent::outNode(n); |
3347 return Parent::outNode(n); |
3162 } |
3348 } |
3163 |
3349 |
3164 /// \brief Returns true when the arc is arc in the original digraph. |
3350 /// \brief Returns \c true if the given arc is an original arc. |
3165 /// |
3351 /// |
3166 /// Returns true when the arc is arc in the original digraph. |
3352 /// Returns \c true if the given arc is one of the arcs in the |
|
3353 /// original digraph. |
3167 static bool origArc(const Arc& a) { |
3354 static bool origArc(const Arc& a) { |
3168 return Parent::origArc(a); |
3355 return Parent::origArc(a); |
3169 } |
3356 } |
3170 |
3357 |
3171 /// \brief Returns true when the arc binds an in-node and an out-node. |
3358 /// \brief Returns \c true if the given arc is a bind arc. |
3172 /// |
3359 /// |
3173 /// Returns true when the arc binds an in-node and an out-node. |
3360 /// Returns \c true if the given arc is a bind arc, i.e. it connects |
|
3361 /// an in-node and an out-node. |
3174 static bool bindArc(const Arc& a) { |
3362 static bool bindArc(const Arc& a) { |
3175 return Parent::bindArc(a); |
3363 return Parent::bindArc(a); |
3176 } |
3364 } |
3177 |
3365 |
3178 /// \brief Gives back the in-node created from the \c node. |
3366 /// \brief Returns the in-node created from the given original node. |
3179 /// |
3367 /// |
3180 /// Gives back the in-node created from the \c node. |
3368 /// Returns the in-node created from the given original node. |
3181 static Node inNode(const DigraphNode& n) { |
3369 static Node inNode(const DigraphNode& n) { |
3182 return Parent::inNode(n); |
3370 return Parent::inNode(n); |
3183 } |
3371 } |
3184 |
3372 |
3185 /// \brief Gives back the out-node created from the \c node. |
3373 /// \brief Returns the out-node created from the given original node. |
3186 /// |
3374 /// |
3187 /// Gives back the out-node created from the \c node. |
3375 /// Returns the out-node created from the given original node. |
3188 static Node outNode(const DigraphNode& n) { |
3376 static Node outNode(const DigraphNode& n) { |
3189 return Parent::outNode(n); |
3377 return Parent::outNode(n); |
3190 } |
3378 } |
3191 |
3379 |
3192 /// \brief Gives back the arc binds the two part of the node. |
3380 /// \brief Returns the bind arc that corresponds to the given |
3193 /// |
3381 /// original node. |
3194 /// Gives back the arc binds the two part of the node. |
3382 /// |
|
3383 /// Returns the bind arc in the adaptor that corresponds to the given |
|
3384 /// original node, i.e. the arc connecting the in-node and out-node |
|
3385 /// of \c n. |
3195 static Arc arc(const DigraphNode& n) { |
3386 static Arc arc(const DigraphNode& n) { |
3196 return Parent::arc(n); |
3387 return Parent::arc(n); |
3197 } |
3388 } |
3198 |
3389 |
3199 /// \brief Gives back the arc of the original arc. |
3390 /// \brief Returns the arc that corresponds to the given original arc. |
3200 /// |
3391 /// |
3201 /// Gives back the arc of the original arc. |
3392 /// Returns the arc in the adaptor that corresponds to the given |
|
3393 /// original arc. |
3202 static Arc arc(const DigraphArc& a) { |
3394 static Arc arc(const DigraphArc& a) { |
3203 return Parent::arc(a); |
3395 return Parent::arc(a); |
3204 } |
3396 } |
3205 |
3397 |
3206 /// \brief NodeMap combined from two original NodeMap |
3398 /// \brief Node map combined from two original node maps |
3207 /// |
3399 /// |
3208 /// This class adapt two of the original digraph NodeMap to |
3400 /// This map adaptor class adapts two node maps of the original digraph |
3209 /// get a node map on the adapted digraph. |
3401 /// to get a node map of the split digraph. |
|
3402 /// Its value type is inherited from the first node map type |
|
3403 /// (\c InNodeMap). |
3210 template <typename InNodeMap, typename OutNodeMap> |
3404 template <typename InNodeMap, typename OutNodeMap> |
3211 class CombinedNodeMap { |
3405 class CombinedNodeMap { |
3212 public: |
3406 public: |
3213 |
3407 |
|
3408 /// The key type of the map |
3214 typedef Node Key; |
3409 typedef Node Key; |
|
3410 /// The value type of the map |
3215 typedef typename InNodeMap::Value Value; |
3411 typedef typename InNodeMap::Value Value; |
3216 |
3412 |
3217 typedef typename MapTraits<InNodeMap>::ReferenceMapTag ReferenceMapTag; |
3413 typedef typename MapTraits<InNodeMap>::ReferenceMapTag ReferenceMapTag; |
3218 typedef typename MapTraits<InNodeMap>::ReturnValue ReturnValue; |
3414 typedef typename MapTraits<InNodeMap>::ReturnValue ReturnValue; |
3219 typedef typename MapTraits<InNodeMap>::ConstReturnValue ConstReturnValue; |
3415 typedef typename MapTraits<InNodeMap>::ConstReturnValue ConstReturnValue; |
3220 typedef typename MapTraits<InNodeMap>::ReturnValue Reference; |
3416 typedef typename MapTraits<InNodeMap>::ReturnValue Reference; |
3221 typedef typename MapTraits<InNodeMap>::ConstReturnValue ConstReference; |
3417 typedef typename MapTraits<InNodeMap>::ConstReturnValue ConstReference; |
3222 |
3418 |
3223 /// \brief Constructor |
3419 /// Constructor |
3224 /// |
|
3225 /// Constructor. |
|
3226 CombinedNodeMap(InNodeMap& in_map, OutNodeMap& out_map) |
3420 CombinedNodeMap(InNodeMap& in_map, OutNodeMap& out_map) |
3227 : _in_map(in_map), _out_map(out_map) {} |
3421 : _in_map(in_map), _out_map(out_map) {} |
3228 |
3422 |
3229 /// \brief The subscript operator. |
3423 /// Returns the value associated with the given key. |
3230 /// |
3424 Value operator[](const Key& key) const { |
3231 /// The subscript operator. |
3425 if (Parent::inNode(key)) { |
|
3426 return _in_map[key]; |
|
3427 } else { |
|
3428 return _out_map[key]; |
|
3429 } |
|
3430 } |
|
3431 |
|
3432 /// Returns a reference to the value associated with the given key. |
3232 Value& operator[](const Key& key) { |
3433 Value& operator[](const Key& key) { |
3233 if (Parent::inNode(key)) { |
3434 if (Parent::inNode(key)) { |
3234 return _in_map[key]; |
3435 return _in_map[key]; |
3235 } else { |
3436 } else { |
3236 return _out_map[key]; |
3437 return _out_map[key]; |
3237 } |
3438 } |
3238 } |
3439 } |
3239 |
3440 |
3240 /// \brief The const subscript operator. |
3441 /// Sets the value associated with the given key. |
3241 /// |
|
3242 /// The const subscript operator. |
|
3243 Value operator[](const Key& key) const { |
|
3244 if (Parent::inNode(key)) { |
|
3245 return _in_map[key]; |
|
3246 } else { |
|
3247 return _out_map[key]; |
|
3248 } |
|
3249 } |
|
3250 |
|
3251 /// \brief The setter function of the map. |
|
3252 /// |
|
3253 /// The setter function of the map. |
|
3254 void set(const Key& key, const Value& value) { |
3442 void set(const Key& key, const Value& value) { |
3255 if (Parent::inNode(key)) { |
3443 if (Parent::inNode(key)) { |
3256 _in_map.set(key, value); |
3444 _in_map.set(key, value); |
3257 } else { |
3445 } else { |
3258 _out_map.set(key, value); |
3446 _out_map.set(key, value); |
3315 typedef typename MapTraits<DigraphArcMap>::ReturnValue |
3508 typedef typename MapTraits<DigraphArcMap>::ReturnValue |
3316 Reference; |
3509 Reference; |
3317 typedef typename MapTraits<DigraphArcMap>::ConstReturnValue |
3510 typedef typename MapTraits<DigraphArcMap>::ConstReturnValue |
3318 ConstReference; |
3511 ConstReference; |
3319 |
3512 |
3320 /// \brief Constructor |
3513 /// Constructor |
3321 /// |
|
3322 /// Constructor. |
|
3323 CombinedArcMap(DigraphArcMap& arc_map, DigraphNodeMap& node_map) |
3514 CombinedArcMap(DigraphArcMap& arc_map, DigraphNodeMap& node_map) |
3324 : _arc_map(arc_map), _node_map(node_map) {} |
3515 : _arc_map(arc_map), _node_map(node_map) {} |
3325 |
3516 |
3326 /// \brief The subscript operator. |
3517 /// Returns the value associated with the given key. |
3327 /// |
3518 Value operator[](const Key& arc) const { |
3328 /// The subscript operator. |
3519 if (Parent::origArc(arc)) { |
|
3520 return _arc_map[arc]; |
|
3521 } else { |
|
3522 return _node_map[arc]; |
|
3523 } |
|
3524 } |
|
3525 |
|
3526 /// Returns a reference to the value associated with the given key. |
|
3527 Value& operator[](const Key& arc) { |
|
3528 if (Parent::origArc(arc)) { |
|
3529 return _arc_map[arc]; |
|
3530 } else { |
|
3531 return _node_map[arc]; |
|
3532 } |
|
3533 } |
|
3534 |
|
3535 /// Sets the value associated with the given key. |
3329 void set(const Arc& arc, const Value& val) { |
3536 void set(const Arc& arc, const Value& val) { |
3330 if (Parent::origArc(arc)) { |
3537 if (Parent::origArc(arc)) { |
3331 _arc_map.set(arc, val); |
3538 _arc_map.set(arc, val); |
3332 } else { |
3539 } else { |
3333 _node_map.set(arc, val); |
3540 _node_map.set(arc, val); |
3334 } |
3541 } |
3335 } |
3542 } |
3336 |
3543 |
3337 /// \brief The const subscript operator. |
|
3338 /// |
|
3339 /// The const subscript operator. |
|
3340 Value operator[](const Key& arc) const { |
|
3341 if (Parent::origArc(arc)) { |
|
3342 return _arc_map[arc]; |
|
3343 } else { |
|
3344 return _node_map[arc]; |
|
3345 } |
|
3346 } |
|
3347 |
|
3348 /// \brief The const subscript operator. |
|
3349 /// |
|
3350 /// The const subscript operator. |
|
3351 Value& operator[](const Key& arc) { |
|
3352 if (Parent::origArc(arc)) { |
|
3353 return _arc_map[arc]; |
|
3354 } else { |
|
3355 return _node_map[arc]; |
|
3356 } |
|
3357 } |
|
3358 |
|
3359 private: |
3544 private: |
3360 DigraphArcMap& _arc_map; |
3545 DigraphArcMap& _arc_map; |
3361 DigraphNodeMap& _node_map; |
3546 DigraphNodeMap& _node_map; |
3362 }; |
3547 }; |
3363 |
3548 |
3364 /// \brief Just gives back a combined arc map |
3549 /// \brief Returns a combined arc map |
3365 /// |
3550 /// |
3366 /// Just gives back a combined arc map |
3551 /// This function just returns a combined arc map. |
3367 template <typename DigraphArcMap, typename DigraphNodeMap> |
3552 template <typename DigraphArcMap, typename DigraphNodeMap> |
3368 static CombinedArcMap<DigraphArcMap, DigraphNodeMap> |
3553 static CombinedArcMap<DigraphArcMap, DigraphNodeMap> |
3369 combinedArcMap(DigraphArcMap& arc_map, DigraphNodeMap& node_map) { |
3554 combinedArcMap(DigraphArcMap& arc_map, DigraphNodeMap& node_map) { |
3370 return CombinedArcMap<DigraphArcMap, DigraphNodeMap>(arc_map, node_map); |
3555 return CombinedArcMap<DigraphArcMap, DigraphNodeMap>(arc_map, node_map); |
3371 } |
3556 } |