dune-istl 2.12-git
Loading...
Searching...
No Matches
graph.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4// vi: set et ts=4 sw=2 sts=2:
5#ifndef DUNE_AMG_GRAPH_HH
6#define DUNE_AMG_GRAPH_HH
7
8#include <cstddef>
9#include <algorithm>
10#include <vector>
11#include <cassert>
12#include <limits>
17
18namespace Dune
19{
20 namespace Amg
21 {
49 template<class M>
51 {
52 public:
56 typedef M Matrix;
57
62
66 typedef typename M::block_type Weight;
67
73 typedef typename M::size_type VertexDescriptor;
74
81
82 enum {
83 /*
84 * @brief Whether Matrix is mutable.
85 */
87 };
88
89
93 template<class C>
95 {
96
97 public:
106
107 friend class EdgeIteratorT<MutableContainer>;
108 friend class EdgeIteratorT<ConstContainer>;
109
110 enum {
113 };
114
118 typedef typename std::conditional<isMutable && C::mutableMatrix,typename Matrix::ColIterator,
119 typename Matrix::ConstColIterator>::type
121
125 typedef typename std::conditional<isMutable && C::mutableMatrix,typename M::block_type,
126 const typename M::block_type>::type
128
137 const ColIterator& end, const EdgeDescriptor& edge);
138
146
151 template<class C1>
153
154 typedef typename std::conditional<std::is_same<C, typename std::remove_const<C>::type>::value && C::mutableMatrix,
155 typename M::block_type, const typename M::block_type>::type
157
162
165
167 bool operator!=(const EdgeIteratorT<typename std::remove_const<C>::type>& other) const;
168
170 bool operator!=(const EdgeIteratorT<const typename std::remove_const<C>::type>& other) const;
171
173 bool operator==(const EdgeIteratorT<typename std::remove_const<C>::type>& other) const;
174
176 bool operator==(const EdgeIteratorT<const typename std::remove_const<C>::type>& other) const;
177
180
183
185 const EdgeDescriptor& operator*() const;
186
189
190 private:
192 VertexDescriptor source_;
194 ColIterator block_;
195 /***
196 * @brief The column iterator positioned at the end of the row
197 * of vertex source_
198 */
199 ColIterator blockEnd_;
201 EdgeDescriptor edge_;
202 };
203
207 template<class C>
209 {
210 public:
219
220 friend class VertexIteratorT<MutableContainer>;
221 friend class VertexIteratorT<ConstContainer>;
222
223 enum {
226 };
227
233 explicit VertexIteratorT(C* graph, const VertexDescriptor& current);
234
242 explicit VertexIteratorT(const VertexDescriptor& current);
243
245
251
254
257
260
263
264 typedef typename std::conditional<std::is_same<C, typename std::remove_const<C>::type>::value && C::mutableMatrix,
265 typename M::block_type, const typename M::block_type>::type
269
275
282
289
290 private:
291 C* graph_;
292 VertexDescriptor current_;
293 };
294
299
304
309
314
320
325
331
337
343
349
357
365
366
374
382
388
393 const Matrix& matrix() const;
394
399
407
412
420 const VertexDescriptor& target) const;
421
422 private:
424 Matrix& matrix_;
426 EdgeDescriptor* start_;
428 MatrixGraph(const MatrixGraph&);
429
430 };
431
441 template<class G, class T>
443 {
444 public:
448 typedef G Graph;
449
454 typedef T Excluded;
455
459 typedef typename Graph::VertexDescriptor VertexDescriptor;
460
462
470 {
471 public:
473
474 EdgeIndexMap(const EdgeDescriptor& firstEdge)
475 : firstEdge_(firstEdge)
476 {}
477
480 : firstEdge_(emap.firstEdge_)
481 {}
482
484 {
485 return edge-firstEdge_;
486 }
487 private:
489 EdgeDescriptor firstEdge_;
492 {}
493 };
494
500
504 class EdgeIterator : public RandomAccessIteratorFacade<EdgeIterator,const EdgeDescriptor>
505 {
506 public:
512 explicit EdgeIterator(const VertexDescriptor& source, const EdgeDescriptor& edge);
513
521 explicit EdgeIterator(const EdgeDescriptor& edge);
522
524 bool equals(const EdgeIterator& other) const;
525
528
531
533
536
538 const VertexDescriptor& target() const;
539
541 const VertexDescriptor& source() const;
542
544
545 private:
547 VertexDescriptor source_;
552 EdgeDescriptor edge_;
553 };
554
559 : public ForwardIteratorFacade<VertexIterator,const VertexDescriptor>
560 {
561 public:
568 explicit VertexIterator(const SubGraph<G,T>* graph, const VertexDescriptor& current,
569 const VertexDescriptor& end);
570
571
578 explicit VertexIterator(const VertexDescriptor& current);
579
582
584 bool equals(const VertexIterator& other) const;
585
591
598
605
606 private:
608 const SubGraph<Graph,T>* graph_;
610 VertexDescriptor current_;
612 VertexDescriptor end_;
613 };
614
619
624
630
636
644
652
657
665
677 const VertexDescriptor& target) const;
685 SubGraph(const Graph& graph, const T& excluded);
686
691
692 private:
694 const T& excluded_;
696 std::size_t noVertices_;
698 VertexDescriptor endVertex_;
700 int noEdges_;
705 VertexDescriptor maxVertex_;
707 VertexDescriptor* edges_;
709 std::ptrdiff_t* start_;
711 std::ptrdiff_t* end_;
713 SubGraph(const SubGraph&)
714 {}
715 };
716
717
721 template<class G, class VP, class VM=IdentityMap>
723 {
724 public:
728 typedef G Graph;
729
733 typedef typename Graph::VertexDescriptor VertexDescriptor;
734
738 typedef typename Graph::EdgeDescriptor EdgeDescriptor;
739
744
756 typedef VM VertexMap;
757
761 typedef typename Graph::EdgeIterator EdgeIterator;
762
766 typedef typename Graph::ConstEdgeIterator ConstEdgeIterator;
767
774
781
788
795
796
797 template<class C>
799 : public std::conditional<std::is_same<typename std::remove_const<C>::type,
800 C>::value,
801 typename Graph::VertexIterator,
802 typename Graph::ConstVertexIterator>::type
803 {
804 friend class VertexIteratorT<const typename std::remove_const<C>::type>;
805 friend class VertexIteratorT<typename std::remove_const<C>::type>;
806 public:
810 typedef typename std::conditional<std::is_same<typename std::remove_const<C>::type,
811 C>::value,
812 typename Graph::VertexIterator,
813 typename Graph::ConstVertexIterator>::type
815
819 typedef typename std::conditional<std::is_same<typename std::remove_const<C>::type,
820 C>::value,
821 typename Graph::EdgeIterator,
822 typename Graph::ConstEdgeIterator>::type
824
830 explicit VertexIteratorT(const Father& iter,
831 C* graph);
832
833
841 explicit VertexIteratorT(const Father& iter);
842
847 template<class C1>
848 VertexIteratorT(const VertexIteratorT<C1>& other);
849
853 typename std::conditional<std::is_same<C,typename std::remove_const<C>::type>::value,
854 VertexProperties&,
855 const VertexProperties&>::type
856 properties() const;
857
864
871
872 private:
876 C* graph_;
877 };
878
882 typedef VertexIteratorT<VertexPropertiesGraph<Graph,
883 VertexProperties,VM> > VertexIterator;
884
888 typedef VertexIteratorT<const VertexPropertiesGraph<Graph,
889 VertexProperties,VM> > ConstVertexIterator;
890
896
902
908
914
920 VertexProperties& getVertexProperties(const VertexDescriptor& vertex);
921
927 const VertexProperties& getVertexProperties(const VertexDescriptor& vertex) const;
928
933 const Graph& graph() const;
934
939
944
952
958 VertexPropertiesGraph(Graph& graph, const VertexMap vmap=VertexMap());
959
960 private:
961 VertexPropertiesGraph(const VertexPropertiesGraph&)
962 {}
963
965 Graph& graph_;
967 VertexMap vmap_;
970
971 };
972
976 template<class G, class VP, class EP, class VM=IdentityMap, class EM=IdentityMap>
978 {
979 public:
983 typedef G Graph;
984
988 typedef typename Graph::VertexDescriptor VertexDescriptor;
989
993 typedef typename Graph::EdgeDescriptor EdgeDescriptor;
994
999
1011 typedef VM VertexMap;
1012
1016 typedef EP EdgeProperties;
1017
1018
1030 typedef EM EdgeMap;
1031
1032 template<class C>
1034 : public std::conditional<std::is_same<typename std::remove_const<C>::type,
1035 C>::value,
1036 typename Graph::EdgeIterator,
1037 typename Graph::ConstEdgeIterator>::type
1038 {
1039
1040 friend class EdgeIteratorT<const typename std::remove_const<C>::type>;
1041 friend class EdgeIteratorT<typename std::remove_const<C>::type>;
1042 public:
1046 typedef typename std::conditional<std::is_same<typename std::remove_const<C>::type,
1047 C>::value,
1048 typename Graph::EdgeIterator,
1049 typename Graph::ConstEdgeIterator>::type
1051
1057 explicit EdgeIteratorT(const Father& iter,
1058 C* graph);
1059
1067 explicit EdgeIteratorT(const Father& iter);
1068
1073 template<class C1>
1074 EdgeIteratorT(const EdgeIteratorT<C1>& other);
1075
1079 typename std::conditional<std::is_same<C,typename std::remove_const<C>::type>::value,
1080 EdgeProperties&,
1081 const EdgeProperties&>::type
1082 properties() const;
1083
1084 private:
1088 C* graph_;
1089 };
1090
1094 typedef EdgeIteratorT<PropertiesGraph<Graph,
1095 VertexProperties,
1096 EdgeProperties,VM,EM> > EdgeIterator;
1097
1101 typedef EdgeIteratorT<const PropertiesGraph<Graph,
1102 VertexProperties,
1103 EdgeProperties,VM,EM> > ConstEdgeIterator;
1104
1110 EdgeIterator beginEdges(const VertexDescriptor& source);
1111
1117 EdgeIterator endEdges(const VertexDescriptor& source);
1118
1124 ConstEdgeIterator beginEdges(const VertexDescriptor& source) const;
1125
1131 ConstEdgeIterator endEdges(const VertexDescriptor& source) const;
1132
1133
1134 template<class C>
1136 : public std::conditional<std::is_same<typename std::remove_const<C>::type,
1137 C>::value,
1138 typename Graph::VertexIterator,
1139 typename Graph::ConstVertexIterator>::type
1140 {
1141 friend class VertexIteratorT<const typename std::remove_const<C>::type>;
1142 friend class VertexIteratorT<typename std::remove_const<C>::type>;
1143 public:
1147 typedef typename std::conditional<std::is_same<typename std::remove_const<C>::type,
1148 C>::value,
1149 typename Graph::VertexIterator,
1150 typename Graph::ConstVertexIterator>::type
1152
1158 explicit VertexIteratorT(const Father& iter,
1159 C* graph);
1160
1161
1169 explicit VertexIteratorT(const Father& iter);
1170
1175 template<class C1>
1176 VertexIteratorT(const VertexIteratorT<C1>& other);
1177
1181 typename std::conditional<std::is_same<C,typename std::remove_const<C>::type>::value,
1182 VertexProperties&,
1183 const VertexProperties&>::type
1184 properties() const;
1185
1192
1198 EdgeIteratorT<C> end() const;
1199
1200 private:
1204 C* graph_;
1205 };
1206
1210 typedef VertexIteratorT<PropertiesGraph<Graph,
1211 VertexProperties,
1212 EdgeProperties,VM,EM> > VertexIterator;
1213
1217 typedef VertexIteratorT<const PropertiesGraph<Graph,
1218 VertexProperties,
1219 EdgeProperties,VM,EM> > ConstVertexIterator;
1220
1226
1232
1238
1244
1250 VertexProperties& getVertexProperties(const VertexDescriptor& vertex);
1251
1257 const VertexProperties& getVertexProperties(const VertexDescriptor& vertex) const;
1258
1265 EdgeDescriptor findEdge(const VertexDescriptor& source,
1266 const VertexDescriptor& target)
1267 {
1268 return graph_.findEdge(source,target);
1269 }
1270
1277
1278
1285
1293 const VertexDescriptor& target);
1294
1302 const VertexDescriptor& target) const;
1303
1308 const Graph& graph() const;
1309
1314
1319
1327
1335 const EdgeMap& emap=EdgeMap());
1336
1337 private:
1339 {}
1340
1342 Graph& graph_;
1345 VertexMap vmap_;
1346 std::vector<VertexProperties> vertexProperties_;
1348 EdgeMap emap_;
1351
1352 };
1353
1354
1359 template<typename G>
1361 {
1362 public:
1366 typedef G Graph;
1370 typedef typename G::VertexProperties VertexProperties;
1374 typedef typename G::VertexDescriptor Vertex;
1375
1381 : graph_(g)
1382 {}
1387 : graph_(0)
1388 {}
1389
1390
1395 VertexProperties& operator[](const Vertex& vertex) const
1396 {
1397 return graph_->getVertexProperties(vertex);
1398 }
1399 private:
1400 Graph* graph_;
1401 };
1402
1407 template<typename G>
1409 {
1410 public:
1414 typedef G Graph;
1418 typedef typename G::EdgeProperties EdgeProperties;
1422 typedef typename G::EdgeDescriptor Edge;
1423
1429 : graph_(g)
1430 {}
1435 : graph_(0)
1436 {}
1437
1442 EdgeProperties& operator[](const Edge& edge) const
1443 {
1444 return graph_->getEdgeProperties(edge);
1445 }
1446 private:
1447 Graph* graph_;
1448 };
1449
1450
1461 template<class G, class V>
1462 int visitNeighbours(const G& graph, const typename G::VertexDescriptor& vertex,
1463 V& visitor);
1464
1465#ifndef DOXYGEN
1466
1467 template<class M>
1469 : matrix_(matrix)
1470 {
1471 if(matrix_.N()!=matrix_.M())
1472 DUNE_THROW(ISTLError, "Matrix has to have as many columns as rows!");
1473
1474 start_ = new EdgeDescriptor[matrix_.N()+1];
1475
1476 typedef typename M::ConstIterator Iterator;
1477 start_[matrix_.begin().index()] = 0;
1478
1479 for(Iterator row=matrix_.begin(); row != matrix_.end(); ++row)
1480 start_[row.index()+1] = start_[row.index()] + row->size();
1481 }
1482
1483 template<class M>
1484 MatrixGraph<M>::~MatrixGraph()
1485 {
1486 delete[] start_;
1487 }
1488
1489 template<class M>
1490 inline std::size_t MatrixGraph<M>::noEdges() const
1491 {
1492 return start_[matrix_.N()];
1493 }
1494
1495 template<class M>
1496 inline std::size_t MatrixGraph<M>::noVertices() const
1497 {
1498 return matrix_.N();
1499 }
1500
1501 template<class M>
1502 inline typename MatrixGraph<M>::VertexDescriptor MatrixGraph<M>::maxVertex() const
1503 {
1504 return matrix_.N()-1;
1505 }
1506
1507 template<class M>
1508 typename MatrixGraph<M>::EdgeDescriptor
1509 MatrixGraph<M>::findEdge(const VertexDescriptor& source,
1510 const VertexDescriptor& target) const
1511 {
1512 const Matrix& matrix = matrix_;
1513 typename M::ConstColIterator found = matrix[source].find(target);
1514 if(found == matrix[source].end())
1516 std::size_t offset = found.offset();
1517 if(target>source)
1518 offset--;
1519
1520 assert(offset<noEdges());
1521
1522 return start_[source]+offset;
1523 }
1524
1525
1526 template<class M>
1527 inline M& MatrixGraph<M>::matrix()
1528 {
1529 return matrix_;
1530 }
1531
1532 template<class M>
1533 inline const M& MatrixGraph<M>::matrix() const
1534 {
1535 return matrix_;
1536 }
1537
1538 template<class M>
1539 template<class C>
1540 MatrixGraph<M>::EdgeIteratorT<C>::EdgeIteratorT(const VertexDescriptor& source, const ColIterator& block,
1541 const ColIterator& end, const EdgeDescriptor& edge)
1542 : source_(source), block_(block), blockEnd_(end), edge_(edge)
1543 {
1544 if(block_!=blockEnd_ && block_.index() == source_) {
1545 // This is the edge from the diagonal to the diagonal. Skip it.
1546 ++block_;
1547 }
1548 }
1549
1550 template<class M>
1551 template<class C>
1552 MatrixGraph<M>::EdgeIteratorT<C>::EdgeIteratorT(const ColIterator& block)
1553 : block_(block)
1554 {}
1555
1556 template<class M>
1557 template<class C>
1558 template<class C1>
1559 MatrixGraph<M>::EdgeIteratorT<C>::EdgeIteratorT(const EdgeIteratorT<C1>& other)
1560 : source_(other.source_), block_(other.block_), blockEnd_(other.blockEnd_), edge_(other.edge_)
1561 {}
1562
1563
1564 template<class M>
1565 template<class C>
1566 inline typename MatrixGraph<M>::template EdgeIteratorT<C>::WeightType&
1567 MatrixGraph<M>::EdgeIteratorT<C>::weight() const
1568 {
1569 return *block_;
1570 }
1571
1572 template<class M>
1573 template<class C>
1574 inline typename MatrixGraph<M>::template EdgeIteratorT<C>& MatrixGraph<M>::EdgeIteratorT<C>::operator++()
1575 {
1576 ++block_;
1577 ++edge_;
1578
1579 if(block_!=blockEnd_ && block_.index() == source_) {
1580 // This is the edge from the diagonal to the diagonal. Skip it.
1581 ++block_;
1582 }
1583
1584 return *this;
1585 }
1586
1587 template<class M>
1588 template<class C>
1589 inline bool MatrixGraph<M>::EdgeIteratorT<C>::operator!=(const typename MatrixGraph<M>::template EdgeIteratorT<typename std::remove_const<C>::type>& other) const
1590 {
1591 return block_!=other.block_;
1592 }
1593
1594 template<class M>
1595 template<class C>
1596 inline bool MatrixGraph<M>::EdgeIteratorT<C>::operator!=(const typename MatrixGraph<M>::template EdgeIteratorT<const typename std::remove_const<C>::type>& other) const
1597 {
1598 return block_!=other.block_;
1599 }
1600
1601 template<class M>
1602 template<class C>
1603 inline bool MatrixGraph<M>::EdgeIteratorT<C>::operator==(const typename MatrixGraph<M>::template EdgeIteratorT<typename std::remove_const<C>::type>& other) const
1604 {
1605 return block_==other.block_;
1606 }
1607
1608 template<class M>
1609 template<class C>
1610 inline bool MatrixGraph<M>::EdgeIteratorT<C>::operator==(const typename MatrixGraph<M>::template EdgeIteratorT<const typename std::remove_const<C>::type>& other) const
1611 {
1612 return block_==other.block_;
1613 }
1614
1615 template<class M>
1616 template<class C>
1617 inline typename MatrixGraph<M>::VertexDescriptor MatrixGraph<M>::EdgeIteratorT<C>::target() const
1618 {
1619 return block_.index();
1620 }
1621
1622 template<class M>
1623 template<class C>
1624 inline typename MatrixGraph<M>::VertexDescriptor MatrixGraph<M>::EdgeIteratorT<C>::source() const
1625 {
1626 return source_;
1627 }
1628
1629 template<class M>
1630 template<class C>
1631 inline const typename MatrixGraph<M>::EdgeDescriptor& MatrixGraph<M>::EdgeIteratorT<C>::operator*() const
1632 {
1633 return edge_;
1634 }
1635
1636 template<class M>
1637 template<class C>
1638 inline const typename MatrixGraph<M>::EdgeDescriptor* MatrixGraph<M>::EdgeIteratorT<C>::operator->() const
1639 {
1640 return &edge_;
1641 }
1642
1643 template<class M>
1644 template<class C>
1645 MatrixGraph<M>::VertexIteratorT<C>::VertexIteratorT(C* graph,
1646 const VertexDescriptor& current)
1647 : graph_(graph), current_(current)
1648 {}
1649
1650
1651 template<class M>
1652 template<class C>
1653 MatrixGraph<M>::VertexIteratorT<C>::VertexIteratorT(const VertexDescriptor& current)
1654 : current_(current)
1655 {}
1656
1657 template<class M>
1658 template<class C>
1659 MatrixGraph<M>::VertexIteratorT<C>::VertexIteratorT(const VertexIteratorT<MutableContainer>& other)
1660 : graph_(other.graph_), current_(other.current_)
1661 {}
1662
1663 template<class M>
1664 template<class C>
1665 inline bool MatrixGraph<M>::VertexIteratorT<C>::operator!=(const VertexIteratorT<MutableContainer>& other) const
1666 {
1667 return current_ != other.current_;
1668 }
1669
1670 template<class M>
1671 template<class C>
1672 inline bool MatrixGraph<M>::VertexIteratorT<C>::operator!=(const VertexIteratorT<ConstContainer>& other) const
1673 {
1674 return current_ != other.current_;
1675 }
1676
1677
1678 template<class M>
1679 template<class C>
1680 inline bool MatrixGraph<M>::VertexIteratorT<C>::operator==(const VertexIteratorT<MutableContainer>& other) const
1681 {
1682 return current_ == other.current_;
1683 }
1684
1685 template<class M>
1686 template<class C>
1687 inline bool MatrixGraph<M>::VertexIteratorT<C>::operator==(const VertexIteratorT<ConstContainer>& other) const
1688 {
1689 return current_ == other.current_;
1690 }
1691
1692 template<class M>
1693 template<class C>
1694 inline typename MatrixGraph<M>::template VertexIteratorT<C>& MatrixGraph<M>::VertexIteratorT<C>::operator++()
1695 {
1696 ++current_;
1697 return *this;
1698 }
1699
1700 template<class M>
1701 template<class C>
1702 inline typename MatrixGraph<M>::template VertexIteratorT<C>::WeightType&
1703 MatrixGraph<M>::VertexIteratorT<C>::weight() const
1704 {
1705 return graph_->matrix()[current_][current_];
1706 }
1707
1708 template<class M>
1709 template<class C>
1710 inline const typename MatrixGraph<M>::VertexDescriptor&
1711 MatrixGraph<M>::VertexIteratorT<C>::operator*() const
1712 {
1713 return current_;
1714 }
1715
1716 template<class M>
1717 template<class C>
1718 inline typename MatrixGraph<M>::template EdgeIteratorT<C>
1719 MatrixGraph<M>::VertexIteratorT<C>::begin() const
1720 {
1721 return graph_->beginEdges(current_);
1722 }
1723
1724 template<class M>
1725 template<class C>
1726 inline typename MatrixGraph<M>::template EdgeIteratorT<C>
1727 MatrixGraph<M>::VertexIteratorT<C>::end() const
1728 {
1729 return graph_->endEdges(current_);
1730 }
1731
1732 template<class M>
1733 inline typename MatrixGraph<M>::template VertexIteratorT<MatrixGraph<M> >
1734 MatrixGraph<M>::begin()
1735 {
1736 return VertexIterator(this,0);
1737 }
1738
1739 template<class M>
1740 inline typename MatrixGraph<M>::template VertexIteratorT<MatrixGraph<M> >
1741 MatrixGraph<M>::end()
1742 {
1743 return VertexIterator(matrix_.N());
1744 }
1745
1746
1747 template<class M>
1748 inline typename MatrixGraph<M>::template VertexIteratorT<const MatrixGraph<M> >
1749 MatrixGraph<M>::begin() const
1750 {
1751 return ConstVertexIterator(this, 0);
1752 }
1753
1754 template<class M>
1755 inline typename MatrixGraph<M>::template VertexIteratorT<const MatrixGraph<M> >
1756 MatrixGraph<M>::end() const
1757 {
1758 return ConstVertexIterator(matrix_.N());
1759 }
1760
1761 template<class M>
1762 inline typename MatrixGraph<M>::template EdgeIteratorT<MatrixGraph<M> >
1763 MatrixGraph<M>::beginEdges(const VertexDescriptor& source)
1764 {
1765 return EdgeIterator(source, matrix_.operator[](source).begin(),
1766 matrix_.operator[](source).end(), start_[source]);
1767 }
1768
1769 template<class M>
1770 inline typename MatrixGraph<M>::template EdgeIteratorT<MatrixGraph<M> >
1771 MatrixGraph<M>::endEdges(const VertexDescriptor& source)
1772 {
1773 return EdgeIterator(matrix_.operator[](source).end());
1774 }
1775
1776
1777 template<class M>
1778 inline typename MatrixGraph<M>::template EdgeIteratorT<const MatrixGraph<M> >
1779 MatrixGraph<M>::beginEdges(const VertexDescriptor& source) const
1780 {
1781 const Matrix& matrix = matrix_;
1782 return ConstEdgeIterator(source, matrix.operator[](source).begin(),
1783 matrix.operator[](source).end(), start_[source]);
1784 }
1785
1786 template<class M>
1787 inline typename MatrixGraph<M>::template EdgeIteratorT<const MatrixGraph<M> >
1788 MatrixGraph<M>::endEdges(const VertexDescriptor& source) const
1789 {
1790 const Matrix& matrix = matrix_;
1791 return ConstEdgeIterator(matrix.operator[](source).end());
1792 }
1793
1794
1795 template<class G, class T>
1796 SubGraph<G,T>::EdgeIterator::EdgeIterator(const VertexDescriptor& source,
1797 const EdgeDescriptor& edge)
1798 : source_(source), edge_(edge)
1799 {}
1800
1801
1802 template<class G, class T>
1803 SubGraph<G,T>::EdgeIterator::EdgeIterator(const EdgeDescriptor& edge)
1804 : edge_(edge)
1805 {}
1806
1807 template<class G, class T>
1808 typename SubGraph<G,T>::EdgeIndexMap SubGraph<G,T>::getEdgeIndexMap()
1809 {
1810 return EdgeIndexMap(edges_);
1811 }
1812
1813 template<class G, class T>
1814 inline bool SubGraph<G,T>::EdgeIterator::equals(const EdgeIterator & other) const
1815 {
1816 return other.edge_==edge_;
1817 }
1818
1819 template<class G, class T>
1820 inline typename SubGraph<G,T>::EdgeIterator& SubGraph<G,T>::EdgeIterator::increment()
1821 {
1822 ++edge_;
1823 return *this;
1824 }
1825
1826 template<class G, class T>
1827 inline typename SubGraph<G,T>::EdgeIterator& SubGraph<G,T>::EdgeIterator::decrement()
1828 {
1829 --edge_;
1830 return *this;
1831 }
1832
1833 template<class G, class T>
1834 inline typename SubGraph<G,T>::EdgeIterator& SubGraph<G,T>::EdgeIterator::advance(std::ptrdiff_t n)
1835 {
1836 edge_+=n;
1837 return *this;
1838 }
1839 template<class G, class T>
1840 inline const typename G::VertexDescriptor& SubGraph<G,T>::EdgeIterator::source() const
1841 {
1842 return source_;
1843 }
1844
1845 template<class G, class T>
1846 inline const typename G::VertexDescriptor& SubGraph<G,T>::EdgeIterator::target() const
1847 {
1848 return *edge_;
1849 }
1850
1851
1852 template<class G, class T>
1853 inline const typename SubGraph<G,T>::EdgeDescriptor& SubGraph<G,T>::EdgeIterator::dereference() const
1854 {
1855 return edge_;
1856 }
1857
1858 template<class G, class T>
1859 inline std::ptrdiff_t SubGraph<G,T>::EdgeIterator::distanceTo(const EdgeIterator & other) const
1860 {
1861 return other.edge_-edge_;
1862 }
1863
1864 template<class G, class T>
1865 SubGraph<G,T>::VertexIterator::VertexIterator(const SubGraph<G,T>* graph,
1866 const VertexDescriptor& current,
1867 const VertexDescriptor& end)
1868 : graph_(graph), current_(current), end_(end)
1869 {
1870 // Skip excluded vertices
1871 typedef typename T::const_iterator Iterator;
1872
1873 for(Iterator vertex = graph_->excluded_.begin();
1874 current_ != end_ && *vertex;
1875 ++vertex)
1876 ++current_;
1877 assert(current_ == end_ || !graph_->excluded_[current_]);
1878 }
1879
1880 template<class G, class T>
1881 SubGraph<G,T>::VertexIterator::VertexIterator(const VertexDescriptor& current)
1882 : current_(current)
1883 {}
1884
1885 template<class G, class T>
1886 inline typename SubGraph<G,T>::VertexIterator& SubGraph<G,T>::VertexIterator::increment()
1887 {
1888 ++current_;
1889 //Skip excluded vertices
1890 while(current_ != end_ && graph_->excluded_[current_])
1891 ++current_;
1892
1893 assert(current_ == end_ || !graph_->excluded_[current_]);
1894 return *this;
1895 }
1896
1897 template<class G, class T>
1898 inline bool SubGraph<G,T>::VertexIterator::equals(const VertexIterator & other) const
1899 {
1900 return current_==other.current_;
1901 }
1902
1903 template<class G, class T>
1904 inline const typename G::VertexDescriptor& SubGraph<G,T>::VertexIterator::dereference() const
1905 {
1906 return current_;
1907 }
1908
1909 template<class G, class T>
1910 inline typename SubGraph<G,T>::EdgeIterator SubGraph<G,T>::VertexIterator::begin() const
1911 {
1912 return graph_->beginEdges(current_);
1913 }
1914
1915 template<class G, class T>
1916 inline typename SubGraph<G,T>::EdgeIterator SubGraph<G,T>::VertexIterator::end() const
1917 {
1918 return graph_->endEdges(current_);
1919 }
1920
1921 template<class G, class T>
1922 inline typename SubGraph<G,T>::VertexIterator SubGraph<G,T>::begin() const
1923 {
1924 return VertexIterator(this, 0, endVertex_);
1925 }
1926
1927
1928 template<class G, class T>
1929 inline typename SubGraph<G,T>::VertexIterator SubGraph<G,T>::end() const
1930 {
1931 return VertexIterator(endVertex_);
1932 }
1933
1934
1935 template<class G, class T>
1936 inline typename SubGraph<G,T>::EdgeIterator SubGraph<G,T>::beginEdges(const VertexDescriptor& source) const
1937 {
1938 return EdgeIterator(source, edges_+start_[source]);
1939 }
1940
1941 template<class G, class T>
1942 inline typename SubGraph<G,T>::EdgeIterator SubGraph<G,T>::endEdges(const VertexDescriptor& source) const
1943 {
1944 return EdgeIterator(edges_+end_[source]);
1945 }
1946
1947 template<class G, class T>
1948 std::size_t SubGraph<G,T>::noVertices() const
1949 {
1950 return noVertices_;
1951 }
1952
1953 template<class G, class T>
1954 inline typename SubGraph<G,T>::VertexDescriptor SubGraph<G,T>::maxVertex() const
1955 {
1956 return maxVertex_;
1957 }
1958
1959 template<class G, class T>
1960 inline std::size_t SubGraph<G,T>::noEdges() const
1961 {
1962 return noEdges_;
1963 }
1964
1965 template<class G, class T>
1966 inline typename SubGraph<G,T>::EdgeDescriptor SubGraph<G,T>::findEdge(const VertexDescriptor& source,
1967 const VertexDescriptor& target) const
1968 {
1969 const EdgeDescriptor edge = std::lower_bound(edges_+start_[source], edges_+end_[source], target);
1970 if(edge==edges_+end_[source] || *edge!=target)
1972
1973 return edge;
1974 }
1975
1976 template<class G, class T>
1977 SubGraph<G,T>::~SubGraph()
1978 {
1979 delete[] edges_;
1980 delete[] end_;
1981 delete[] start_;
1982 }
1983
1984 template<class G, class T>
1985 SubGraph<G,T>::SubGraph(const G& graph, const T& excluded)
1986 : excluded_(excluded), noVertices_(0), endVertex_(0), maxVertex_(graph.maxVertex())
1987 {
1988 start_ = new std::ptrdiff_t[graph.noVertices()];
1989 end_ = new std::ptrdiff_t[graph.noVertices()];
1990 edges_ = new VertexDescriptor[graph.noEdges()];
1991
1992 VertexDescriptor* edge=edges_;
1993
1994 // Cater for the case that there are no vertices.
1995 // Otherwise endVertex_ will get 1 below.
1996 if ( graph.noVertices() == 0)
1997 return;
1998
1999 typedef typename Graph::ConstVertexIterator Iterator;
2000 Iterator endVertex=graph.end();
2001
2002 for(Iterator vertex = graph.begin(); vertex != endVertex; ++vertex)
2003 if(excluded_[*vertex])
2004 start_[*vertex]=end_[*vertex]=-1;
2005 else{
2006 ++noVertices_;
2007 endVertex_ = std::max(*vertex, endVertex_);
2008
2009 start_[*vertex] = edge-edges_;
2010
2011 auto endEdge = vertex.end();
2012
2013 for(auto iter=vertex.begin(); iter!= endEdge; ++iter)
2014 if(!excluded[iter.target()]) {
2015 *edge = iter.target();
2016 ++edge;
2017 }
2018
2019 end_[*vertex] = edge - edges_;
2020
2021 // Sort the edges
2022 std::sort(edges_+start_[*vertex], edge);
2023 }
2024 noEdges_ = edge-edges_;
2025 ++endVertex_;
2026 }
2027
2028 template<class G, class V, class VM>
2029 inline std::size_t VertexPropertiesGraph<G,V,VM>::noEdges() const
2030 {
2031 return graph_.noEdges();
2032 }
2033
2034 template<class G, class V, class VM>
2035 inline typename VertexPropertiesGraph<G,V,VM>::EdgeIterator
2036 VertexPropertiesGraph<G,V,VM>::beginEdges(const VertexDescriptor& source)
2037 {
2038 return graph_.beginEdges(source);
2039 }
2040
2041 template<class G, class V, class VM>
2042 inline typename VertexPropertiesGraph<G,V,VM>::EdgeIterator
2043 VertexPropertiesGraph<G,V,VM>::endEdges(const VertexDescriptor& source)
2044 {
2045 return graph_.endEdges(source);
2046 }
2047
2048 template<class G, class V, class VM>
2049 typename VertexPropertiesGraph<G,V,VM>::ConstEdgeIterator
2050 inline VertexPropertiesGraph<G,V,VM>::beginEdges(const VertexDescriptor& source) const
2051 {
2052 return graph_.beginEdges(source);
2053 }
2054
2055 template<class G, class V, class VM>
2056 typename VertexPropertiesGraph<G,V,VM>::ConstEdgeIterator
2057 VertexPropertiesGraph<G,V,VM>::endEdges(const VertexDescriptor& source) const
2058 {
2059 return graph_.endEdges(source);
2060 }
2061
2062 template<class G, class V, class VM>
2063 template<class C>
2064 VertexPropertiesGraph<G,V,VM>::VertexIteratorT<C>
2065 ::VertexIteratorT(const Father& iter,
2066 C* graph)
2067 : Father(iter), graph_(graph)
2068 {}
2069
2070 template<class G, class V, class VM>
2071 template<class C>
2072 VertexPropertiesGraph<G,V,VM>::VertexIteratorT<C>
2073 ::VertexIteratorT(const Father& iter)
2074 : Father(iter)
2075 {}
2076
2077 template<class G, class V, class VM>
2078 template<class C>
2079 template<class C1>
2080 VertexPropertiesGraph<G,V,VM>::VertexIteratorT<C>
2081 ::VertexIteratorT(const VertexIteratorT<C1>& other)
2082 : Father(other), graph_(other.graph_)
2083 {}
2084
2085 template<class G, class V, class VM>
2086 template<class C>
2088 V&, const V&>::type
2089 inline VertexPropertiesGraph<G,V,VM>::VertexIteratorT<C>::properties() const
2090 {
2091 return graph_->getVertexProperties(Father::operator*());
2092 }
2093
2094 template<class G, class V, class VM>
2095 template<class C>
2097 C>::value,
2098 typename G::EdgeIterator,
2099 typename G::ConstEdgeIterator>::type
2100 inline VertexPropertiesGraph<G,V,VM>::VertexIteratorT<C>::begin() const
2101 {
2102 return graph_->beginEdges(Father::operator*());
2103 }
2104
2105 template<class G, class V, class VM>
2106 template<class C>
2108 C>::value,
2109 typename G::EdgeIterator,
2110 typename G::ConstEdgeIterator>::type
2111 inline VertexPropertiesGraph<G,V,VM>::VertexIteratorT<C>::end() const
2112 {
2113 return graph_->endEdges(Father::operator*());
2114 }
2115
2116 template<class G, class V, class VM>
2117 inline typename VertexPropertiesGraph<G,V,VM>::VertexIterator VertexPropertiesGraph<G,V,VM>::begin()
2118 {
2119 return VertexIterator(graph_.begin(), this);
2120 }
2121
2122 template<class G, class V, class VM>
2123 inline typename VertexPropertiesGraph<G,V,VM>::VertexIterator VertexPropertiesGraph<G,V,VM>::end()
2124 {
2125 return VertexIterator(graph_.end());
2126 }
2127
2128
2129 template<class G, class V, class VM>
2130 inline typename VertexPropertiesGraph<G,V,VM>::ConstVertexIterator VertexPropertiesGraph<G,V,VM>::begin() const
2131 {
2132 return ConstVertexIterator(graph_.begin(), this);
2133 }
2134
2135 template<class G, class V, class VM>
2136 inline typename VertexPropertiesGraph<G,V,VM>::ConstVertexIterator VertexPropertiesGraph<G,V,VM>::end() const
2137 {
2138 return ConstVertexIterator(graph_.end());
2139 }
2140
2141 template<class G, class V, class VM>
2142 inline V& VertexPropertiesGraph<G,V,VM>::getVertexProperties(const VertexDescriptor& vertex)
2143 {
2144 return vertexProperties_[vmap_[vertex]];
2145 }
2146
2147 template<class G, class V, class VM>
2148 inline const V& VertexPropertiesGraph<G,V,VM>::getVertexProperties(const VertexDescriptor& vertex) const
2149 {
2150 return vertexProperties_[vmap_[vertex]];
2151 }
2152
2153 template<class G, class V, class VM>
2154 inline const G& VertexPropertiesGraph<G,V,VM>::graph() const
2155 {
2156 return graph_;
2157 }
2158
2159 template<class G, class V, class VM>
2160 inline std::size_t VertexPropertiesGraph<G,V,VM>::noVertices() const
2161 {
2162 return graph_.noVertices();
2163 }
2164
2165
2166 template<class G, class V, class VM>
2167 inline typename VertexPropertiesGraph<G,V,VM>::VertexDescriptor VertexPropertiesGraph<G,V,VM>::maxVertex() const
2168 {
2169 return graph_.maxVertex();
2170 }
2171
2172 template<class G, class V, class VM>
2173 VertexPropertiesGraph<G,V,VM>::VertexPropertiesGraph(Graph& graph, const VM vmap)
2174 : graph_(graph), vmap_(vmap), vertexProperties_(vmap_[graph_.maxVertex()+1], V())
2175 {}
2176
2177 template<class G, class V, class E, class VM, class EM>
2178 template<class C>
2179 PropertiesGraph<G,V,E,VM,EM>::EdgeIteratorT<C>::EdgeIteratorT(const Father& iter,
2180 C* graph)
2181 : Father(iter), graph_(graph)
2182 {}
2183
2184 template<class G, class V, class E, class VM, class EM>
2185 template<class C>
2186 PropertiesGraph<G,V,E,VM,EM>::EdgeIteratorT<C>::EdgeIteratorT(const Father& iter)
2187 : Father(iter)
2188 {}
2189
2190 template<class G, class V, class E, class VM, class EM>
2191 template<class C>
2192 template<class C1>
2193 PropertiesGraph<G,V,E,VM,EM>::EdgeIteratorT<C>::EdgeIteratorT(const EdgeIteratorT<C1>& other)
2194 : Father(other), graph_(other.graph_)
2195 {}
2196
2197
2198 template<class G, class V, class E, class VM, class EM>
2199 inline std::size_t PropertiesGraph<G,V,E,VM,EM>::noEdges() const
2200 {
2201 return graph_.noEdges();
2202 }
2203
2204 template<class G, class V, class E, class VM, class EM>
2205 template<class C>
2206 inline typename std::conditional<std::is_same<C,typename std::remove_const<C>::type>::value,E&,const E&>::type
2207 PropertiesGraph<G,V,E,VM,EM>::EdgeIteratorT<C>::properties() const
2208 {
2209 return graph_->getEdgeProperties(Father::operator*());
2210 }
2211
2212 template<class G, class V, class E, class VM, class EM>
2213 inline typename PropertiesGraph<G,V,E,VM,EM>::EdgeIterator
2214 PropertiesGraph<G,V,E,VM,EM>::beginEdges(const VertexDescriptor& source)
2215 {
2216 return EdgeIterator(graph_.beginEdges(source), this);
2217 }
2218
2219 template<class G, class V, class E, class VM, class EM>
2220 inline typename PropertiesGraph<G,V,E,VM,EM>::EdgeIterator
2221 PropertiesGraph<G,V,E,VM,EM>::endEdges(const VertexDescriptor& source)
2222 {
2223 return EdgeIterator(graph_.endEdges(source));
2224 }
2225
2226 template<class G, class V, class E, class VM, class EM>
2227 typename PropertiesGraph<G,V,E,VM,EM>::ConstEdgeIterator
2228 inline PropertiesGraph<G,V,E,VM,EM>::beginEdges(const VertexDescriptor& source) const
2229 {
2230 return ConstEdgeIterator(graph_.beginEdges(source), this);
2231 }
2232
2233 template<class G, class V, class E, class VM, class EM>
2234 typename PropertiesGraph<G,V,E,VM,EM>::ConstEdgeIterator
2235 PropertiesGraph<G,V,E,VM,EM>::endEdges(const VertexDescriptor& source) const
2236 {
2237 return ConstEdgeIterator(graph_.endEdges(source));
2238 }
2239
2240 template<class G, class V, class E, class VM, class EM>
2241 template<class C>
2242 PropertiesGraph<G,V,E,VM,EM>::VertexIteratorT<C>
2243 ::VertexIteratorT(const Father& iter,
2244 C* graph)
2245 : Father(iter), graph_(graph)
2246 {}
2247
2248 template<class G, class V, class E, class VM, class EM>
2249 template<class C>
2250 PropertiesGraph<G,V,E,VM,EM>::VertexIteratorT<C>
2251 ::VertexIteratorT(const Father& iter)
2252 : Father(iter)
2253 {}
2254
2255 template<class G, class V, class E, class VM, class EM>
2256 template<class C>
2257 template<class C1>
2258 PropertiesGraph<G,V,E,VM,EM>::VertexIteratorT<C>
2259 ::VertexIteratorT(const VertexIteratorT<C1>& other)
2260 : Father(other), graph_(other.graph_)
2261 {}
2262
2263 template<class G, class V, class E, class VM, class EM>
2264 template<class C>
2266 V&, const V&>::type
2267 PropertiesGraph<G,V,E,VM,EM>::VertexIteratorT<C>::properties() const
2268 {
2269 return graph_->getVertexProperties(Father::operator*());
2270 }
2271
2272 template<class G, class V, class E, class VM, class EM>
2273 template<class C>
2274 inline typename PropertiesGraph<G,V,E,VM,EM>::template EdgeIteratorT<C>
2275 PropertiesGraph<G,V,E,VM,EM>::VertexIteratorT<C>::begin() const
2276 {
2277 return graph_->beginEdges(Father::operator*());
2278 }
2279
2280 template<class G, class V, class E, class VM, class EM>
2281 template<class C>
2282 inline typename PropertiesGraph<G,V,E,VM,EM>::template EdgeIteratorT<C>
2283 PropertiesGraph<G,V,E,VM,EM>::VertexIteratorT<C>::end() const
2284 {
2285 return graph_->endEdges(Father::operator*());
2286 }
2287
2288 template<class G, class V, class E, class VM, class EM>
2289 inline typename PropertiesGraph<G,V,E,VM,EM>::VertexIterator PropertiesGraph<G,V,E,VM,EM>::begin()
2290 {
2291 return VertexIterator(graph_.begin(), this);
2292 }
2293
2294 template<class G, class V, class E, class VM, class EM>
2295 inline typename PropertiesGraph<G,V,E,VM,EM>::VertexIterator PropertiesGraph<G,V,E,VM,EM>::end()
2296 {
2297 return VertexIterator(graph_.end());
2298 }
2299
2300
2301 template<class G, class V, class E, class VM, class EM>
2302 inline typename PropertiesGraph<G,V,E,VM,EM>::ConstVertexIterator PropertiesGraph<G,V,E,VM,EM>::begin() const
2303 {
2304 return ConstVertexIterator(graph_.begin(), this);
2305 }
2306
2307 template<class G, class V, class E, class VM, class EM>
2308 inline typename PropertiesGraph<G,V,E,VM,EM>::ConstVertexIterator PropertiesGraph<G,V,E,VM,EM>::end() const
2309 {
2310 return ConstVertexIterator(graph_.end());
2311 }
2312
2313 template<class G, class V, class E, class VM, class EM>
2314 inline V& PropertiesGraph<G,V,E,VM,EM>::getVertexProperties(const VertexDescriptor& vertex)
2315 {
2316 return vertexProperties_[vmap_[vertex]];
2317 }
2318
2319 template<class G, class V, class E, class VM, class EM>
2320 inline const V& PropertiesGraph<G,V,E,VM,EM>::getVertexProperties(const VertexDescriptor& vertex) const
2321 {
2322 return vertexProperties_[vmap_[vertex]];
2323 }
2324
2325 template<class G, class V, class E, class VM, class EM>
2326 inline E& PropertiesGraph<G,V,E,VM,EM>::getEdgeProperties(const EdgeDescriptor& edge)
2327 {
2328 return edgeProperties_[emap_[edge]];
2329 }
2330
2331 template<class G, class V, class E, class VM, class EM>
2332 inline const E& PropertiesGraph<G,V,E,VM,EM>::getEdgeProperties(const EdgeDescriptor& edge) const
2333 {
2334 return edgeProperties_[emap_[edge]];
2335 }
2336
2337 template<class G, class V, class E, class VM, class EM>
2338 inline E& PropertiesGraph<G,V,E,VM,EM>::getEdgeProperties(const VertexDescriptor& source,
2339 const VertexDescriptor& target)
2340 {
2341 return getEdgeProperties(graph_.findEdge(source,target));
2342 }
2343
2344 template<class G, class V, class E, class VM, class EM>
2345 inline const E& PropertiesGraph<G,V,E,VM,EM>::getEdgeProperties(const VertexDescriptor& source,
2346 const VertexDescriptor& target) const
2347 {
2348 return getEdgeProperties(graph_.findEdge(source,target));
2349 }
2350
2351 template<class G, class V, class E, class VM, class EM>
2352 inline const G& PropertiesGraph<G,V,E,VM,EM>::graph() const
2353 {
2354 return graph_;
2355 }
2356
2357 template<class G, class V, class E, class VM, class EM>
2358 inline std::size_t PropertiesGraph<G,V,E,VM,EM>::noVertices() const
2359 {
2360 return graph_.noVertices();
2361 }
2362
2363
2364 template<class G, class V, class E, class VM, class EM>
2365 inline typename PropertiesGraph<G,V,E,VM,EM>::VertexDescriptor PropertiesGraph<G,V,E,VM,EM>::maxVertex() const
2366 {
2367 return graph_.maxVertex();
2368 }
2369
2370 template<class G, class V, class E, class VM, class EM>
2371 PropertiesGraph<G,V,E,VM,EM>::PropertiesGraph(Graph& graph, const VM& vmap, const EM& emap)
2372 : graph_(graph), vmap_(vmap), vertexProperties_(vmap_[graph_.maxVertex()+1], V()),
2373 emap_(emap), edgeProperties_(graph_.noEdges(), E())
2374 {}
2375
2376 template<class G, class V>
2377 inline int visitNeighbours(const G& graph, const typename G::VertexDescriptor& vertex,
2378 V& visitor)
2379 {
2380 typedef typename G::ConstEdgeIterator iterator;
2381 const iterator end = graph.endEdges(vertex);
2382 int noNeighbours=0;
2383 for(iterator edge = graph.beginEdges(vertex); edge != end; ++edge, ++noNeighbours)
2384 visitor(edge);
2385 return noNeighbours;
2386 }
2387
2388#endif // DOXYGEN
2389
2391 }
2392}
2393#endif
int visitNeighbours(const G &graph, const typename G::VertexDescriptor &vertex, V &visitor)
Visit all neighbour vertices of a vertex in a graph.
STL namespace.
iterator end()
iterator begin()
static constexpr size_type M()
#define DUNE_THROW(E,...)
iterator(ParallelIndexSet< TG, TL, N > &indexSet, const Father &father)
derive error class from the base class in common
Definition istlexception.hh:19
row_type::iterator ColIterator
Iterator for the entries of each row.
Definition matrix.hh:583
row_type::const_iterator ConstColIterator
Const iterator for the entries of each row.
Definition matrix.hh:589
The (undirected) graph of a matrix.
Definition graph.hh:51
MatrixGraph(Matrix &matrix)
Constructor.
VertexIterator end()
Get an iterator over the vertices.
VertexDescriptor maxVertex() const
Get the maximal vertex descriptor.
M Matrix
The type of the matrix we are a graph for.
Definition graph.hh:56
ConstVertexIterator begin() const
Get an iterator over the vertices.
VertexIteratorT< const MatrixGraph< Matrix > > ConstVertexIterator
The constant vertex iterator type.
Definition graph.hh:308
~MatrixGraph()
Destructor.
@ mutableMatrix
Definition graph.hh:86
std::ptrdiff_t EdgeDescriptor
The edge descriptor.
Definition graph.hh:80
ConstEdgeIterator endEdges(const VertexDescriptor &source) const
Get an iterator over the edges starting at a vertex.
M::size_type VertexDescriptor
The vertex descriptor.
Definition graph.hh:73
const Matrix & matrix() const
Get the underlying matrix.
ConstEdgeIterator beginEdges(const VertexDescriptor &source) const
Get an iterator over the edges starting at a vertex.
ConstVertexIterator end() const
Get an iterator over the vertices.
EdgeIteratorT< const MatrixGraph< Matrix > > ConstEdgeIterator
The constant edge iterator type.
Definition graph.hh:298
EdgeIterator beginEdges(const VertexDescriptor &source)
Get an iterator over the edges starting at a vertex.
std::size_t noVertices() const
Get the number of vertices in the graph.
EdgeDescriptor findEdge(const VertexDescriptor &source, const VertexDescriptor &target) const
Find the descriptor of an edge.
M::block_type Weight
The type of the weights.
Definition graph.hh:66
std::remove_const< M >::type MutableMatrix
The mutable type of the matrix we are a graph for.
Definition graph.hh:61
EdgeIteratorT< MatrixGraph< Matrix > > EdgeIterator
The mutable edge iterator type.
Definition graph.hh:303
VertexIteratorT< MatrixGraph< Matrix > > VertexIterator
The mutable vertex iterator type.
Definition graph.hh:313
EdgeIterator endEdges(const VertexDescriptor &source)
Get an iterator over the edges starting at a vertex.
std::size_t noEdges() const
Get the number of edges in the graph.
Matrix & matrix()
Get the underlying matrix.
VertexIterator begin()
Get an iterator over the vertices.
Iterator over all edges starting from a vertex.
Definition graph.hh:95
std::conditional< std::is_same< C, typenamestd::remove_const< C >::type >::value &&C::mutableMatrix, typenameM::block_type, consttypenameM::block_type >::type WeightType
Definition graph.hh:156
EdgeIteratorT(const VertexDescriptor &source, const ColIterator &block, const ColIterator &end, const EdgeDescriptor &edge)
Constructor.
VertexDescriptor target() const
The index of the target vertex of the current edge.
EdgeIteratorT< C > & operator++()
preincrement operator.
bool operator!=(const EdgeIteratorT< const typename std::remove_const< C >::type > &other) const
Inequality operator.
bool operator==(const EdgeIteratorT< const typename std::remove_const< C >::type > &other) const
Equality operator.
EdgeIteratorT(const EdgeIteratorT< C1 > &other)
Copy Constructor.
@ isMutable
whether C is mutable.
Definition graph.hh:112
bool operator!=(const EdgeIteratorT< typename std::remove_const< C >::type > &other) const
Inequality operator.
WeightType & weight() const
Access the edge weight.
VertexDescriptor source() const
The index of the source vertex of the current edge.
const std::remove_const< C >::type ConstContainer
The constant type of the container type.
Definition graph.hh:105
bool operator==(const EdgeIteratorT< typename std::remove_const< C >::type > &other) const
Equality operator.
EdgeIteratorT(const ColIterator &block)
Constructor for the end iterator.
std::conditional< isMutable &&C::mutableMatrix, typenameM::block_type, consttypenameM::block_type >::type Weight
The matrix block type we use as weights.
Definition graph.hh:127
const EdgeDescriptor & operator*() const
Get the edge descriptor.
const EdgeDescriptor * operator->() const
Get the edge descriptor.
std::remove_const< C >::type MutableContainer
The mutable type of the container type.
Definition graph.hh:101
std::conditional< isMutable &&C::mutableMatrix, typenameMatrix::ColIterator, typenameMatrix::ConstColIterator >::type ColIterator
The column iterator of the matrix we use.
Definition graph.hh:120
The vertex iterator type of the graph.
Definition graph.hh:209
EdgeIteratorT< C > begin() const
Get an iterator over all edges starting at the current vertex.
const VertexDescriptor & operator*() const
Get the descriptor of the current vertex.
WeightType & weight() const
Access the weight of the vertex.
VertexIteratorT(C *graph, const VertexDescriptor &current)
Constructor.
@ isMutable
whether C is mutable.
Definition graph.hh:225
std::conditional< std::is_same< C, typenamestd::remove_const< C >::type >::value &&C::mutableMatrix, typenameM::block_type, consttypenameM::block_type >::type WeightType
Definition graph.hh:266
VertexIteratorT(const VertexIteratorT< MutableContainer > &other)
std::remove_const< C >::type MutableContainer
The mutable type of the container type.
Definition graph.hh:214
bool operator!=(const VertexIteratorT< MutableContainer > &other) const
Inequality operator.
bool operator==(const VertexIteratorT< MutableContainer > &other) const
Equality operator.
const std::remove_const< C >::type ConstContainer
The constant type of the container type.
Definition graph.hh:218
VertexIteratorT< C > & operator++()
Move to the next vertex.
EdgeIteratorT< C > end() const
Get an iterator over all edges starting at the current vertex.
bool operator==(const VertexIteratorT< ConstContainer > &other) const
Equality operator.
bool operator!=(const VertexIteratorT< ConstContainer > &other) const
Inequality operator.
VertexIteratorT(const VertexDescriptor &current)
Constructor for the end iterator.
A subgraph of a graph.
Definition graph.hh:443
EdgeDescriptor findEdge(const VertexDescriptor &source, const VertexDescriptor &target) const
Find the descriptor of an edge.
VertexDescriptor maxVertex() const
Get the maximal vertex descriptor.
EdgeIndexMap getEdgeIndexMap()
Get an edge index map for the graph.
std::size_t noEdges() const
Get the number of edges in the graph.
ConstEdgeIterator endEdges(const VertexDescriptor &source) const
Get an iterator over the edges starting at a vertex.
ConstVertexIterator end() const
Get an iterator over the vertices.
ConstEdgeIterator beginEdges(const VertexDescriptor &source) const
Get an iterator over the edges starting at a vertex.
std::size_t noVertices() const
Get the number of vertices in the graph.
T Excluded
Random access container providing information about which vertices are excluded.
Definition graph.hh:454
~SubGraph()
Destructor.
EdgeIterator ConstEdgeIterator
The constant edge iterator type.
Definition graph.hh:618
G Graph
The type of the graph we are a sub graph for.
Definition graph.hh:448
VertexIterator ConstVertexIterator
The constant vertex iterator type.
Definition graph.hh:623
SubGraph(const Graph &graph, const T &excluded)
Constructor.
ConstVertexIterator begin() const
Get an iterator over the vertices.
Graph::VertexDescriptor VertexDescriptor
The vertex descriptor.
Definition graph.hh:459
VertexDescriptor * EdgeDescriptor
Definition graph.hh:461
An index map for mapping the edges to indices.
Definition graph.hh:470
EdgeIndexMap(const EdgeIndexMap &emap)
Protect copy construction.
Definition graph.hh:479
ReadablePropertyMapTag Category
Definition graph.hh:472
EdgeIndexMap(const EdgeDescriptor &firstEdge)
Definition graph.hh:474
std::size_t operator[](const EdgeDescriptor &edge) const
Definition graph.hh:483
The edge iterator of the graph.
Definition graph.hh:505
const EdgeDescriptor & dereference() const
The descriptor of the current edge.
EdgeIterator(const EdgeDescriptor &edge)
Constructor for the end iterator.
bool equals(const EdgeIterator &other) const
Equality operator.
EdgeIterator & advance(std::ptrdiff_t n)
EdgeIterator & increment()
Preincrement operator.
const VertexDescriptor & target() const
The index of the target vertex of the current edge.
const VertexDescriptor & source() const
The index of the source vertex of the current edge.
EdgeIterator & decrement()
Preincrement operator.
std::ptrdiff_t distanceTo(const EdgeIterator &other) const
EdgeIterator(const VertexDescriptor &source, const EdgeDescriptor &edge)
Constructor.
The vertex iterator of the graph.
Definition graph.hh:560
VertexIterator(const VertexDescriptor &current)
Constructor for end iterator.
VertexIterator & increment()
Preincrement operator.
EdgeIterator begin() const
Get an iterator over all edges starting at the current vertex.
bool equals(const VertexIterator &other) const
Equality iterator.
VertexIterator(const SubGraph< G, T > *graph, const VertexDescriptor &current, const VertexDescriptor &end)
Constructor.
EdgeIterator end() const
Get an iterator over all edges starting at the current vertex.
const VertexDescriptor & dereference() const
Get the descriptor of the current vertex.
Attaches properties to the vertices of a graph.
Definition graph.hh:723
const Graph & graph() const
Get the graph the properties are attached to.
Graph::ConstEdgeIterator ConstEdgeIterator
The type of the constant edge iterator.
Definition graph.hh:766
VertexProperties & getVertexProperties(const VertexDescriptor &vertex)
Get the properties associated with a vertex.
std::size_t noEdges() const
Get the number of edges in the graph.
Graph::EdgeDescriptor EdgeDescriptor
The edge descritor.
Definition graph.hh:738
ConstEdgeIterator endEdges(const VertexDescriptor &source) const
Get the mutable edge iterator over edges starting at a vertex.
Graph::VertexDescriptor VertexDescriptor
The vertex descriptor.
Definition graph.hh:733
G Graph
The graph we attach properties to.
Definition graph.hh:728
VM VertexMap
The type of the map for converting the VertexDescriptor to std::size_t.
Definition graph.hh:756
EdgeIterator endEdges(const VertexDescriptor &source)
Get the mutable edge iterator over edges starting at a vertex.
EdgeIterator beginEdges(const VertexDescriptor &source)
Get the mutable edge iterator over edges starting at a vertex.
VP VertexProperties
The type of the properties of the vertices.
Definition graph.hh:743
std::size_t noVertices() const
Get the number of vertices in the graph.
ConstEdgeIterator beginEdges(const VertexDescriptor &source) const
Get the mutable edge iterator over edges starting at a vertex.
VertexDescriptor maxVertex() const
Get the maximal vertex descriptor.
Graph::EdgeIterator EdgeIterator
The type of the mutable edge iterator.
Definition graph.hh:761
std::conditional< std::is_same< typenamestd::remove_const< C >::type, C >::value, typenameGraph::EdgeIterator, typenameGraph::ConstEdgeIterator >::type EdgeIterator
The class of the edge iterator.
Definition graph.hh:823
std::conditional< std::is_same< C, typenamestd::remove_const< C >::type >::value, VertexProperties &, constVertexProperties & >::type properties() const
Get the properties of the current Vertex.
EdgeIterator end() const
Get an iterator over the edges starting from the current vertex.
std::conditional< std::is_same< typenamestd::remove_const< C >::type, C >::value, typenameGraph::VertexIterator, typenameGraph::ConstVertexIterator >::type Father
The father class.
Definition graph.hh:814
EdgeIterator begin() const
Get an iterator over the edges starting from the current vertex.
Attaches properties to the edges and vertices of a graph.
Definition graph.hh:978
std::size_t noVertices() const
Get the number of vertices in the graph.
Graph::EdgeDescriptor EdgeDescriptor
The edge descritor.
Definition graph.hh:993
const EdgeProperties & getEdgeProperties(const VertexDescriptor &source, const VertexDescriptor &target) const
Get the properties associated with a edge.
const EdgeProperties & getEdgeProperties(const EdgeDescriptor &edge) const
Get the properties associated with a edge.
const Graph & graph() const
Get the graph the properties are attached to.
VertexDescriptor maxVertex() const
Get the maximal vertex descriptor.
G Graph
The graph we attach properties to.
Definition graph.hh:983
EM EdgeMap
The type of the map for converting the EdgeDescriptor to std::size_t.
Definition graph.hh:1030
VM VertexMap
The type of the map for converting the VertexDescriptor to std::size_t.
Definition graph.hh:1011
VP VertexProperties
The type of the properties of the vertices.
Definition graph.hh:998
std::size_t noEdges() const
Get the number of edges in the graph.
EP EdgeProperties
The type of the properties of the edges;.
Definition graph.hh:1016
EdgeProperties & getEdgeProperties(const VertexDescriptor &source, const VertexDescriptor &target)
Get the properties associated with a edge.
EdgeProperties & getEdgeProperties(const EdgeDescriptor &edge)
Get the properties associated with a edge.
Graph::VertexDescriptor VertexDescriptor
The vertex descriptor.
Definition graph.hh:988
PropertiesGraph(Graph &graph, const VertexMap &vmap=VertexMap(), const EdgeMap &emap=EdgeMap())
Constructor.
std::conditional< std::is_same< typenamestd::remove_const< C >::type, C >::value, typenameGraph::EdgeIterator, typenameGraph::ConstEdgeIterator >::type Father
The father class.
Definition graph.hh:1050
std::conditional< std::is_same< typenamestd::remove_const< C >::type, C >::value, typenameGraph::VertexIterator, typenameGraph::ConstVertexIterator >::type Father
The father class.
Definition graph.hh:1151
Wrapper to access the internal edge properties of a graph via operator[]()
Definition graph.hh:1361
GraphVertexPropertiesSelector(G &g)
Constructor.
Definition graph.hh:1380
VertexProperties & operator[](const Vertex &vertex) const
Get the properties associated to a vertex.
Definition graph.hh:1395
G Graph
The type of the graph with internal properties.
Definition graph.hh:1366
G::VertexProperties VertexProperties
The type of the vertex properties.
Definition graph.hh:1370
GraphVertexPropertiesSelector()
Default constructor.
Definition graph.hh:1386
G::VertexDescriptor Vertex
The vertex descriptor.
Definition graph.hh:1374
Wrapper to access the internal vertex properties of a graph via operator[]()
Definition graph.hh:1409
EdgeProperties & operator[](const Edge &edge) const
Get the properties associated to a vertex.
Definition graph.hh:1442
G::EdgeProperties EdgeProperties
The type of the vertex properties.
Definition graph.hh:1418
G::EdgeDescriptor Edge
The edge descriptor.
Definition graph.hh:1422
GraphEdgePropertiesSelector()
Default constructor.
Definition graph.hh:1434
G Graph
The type of the graph with internal properties.
Definition graph.hh:1414
GraphEdgePropertiesSelector(G &g)
Constructor.
Definition graph.hh:1428
T lower_bound(T... args)
T max(T... args)
T sort(T... args)