3 #ifndef DUNE_AMG_GRAPH_HH
4 #define DUNE_AMG_GRAPH_HH
11 #include <dune/common/typetraits.hh>
12 #include <dune/common/iteratorfacades.hh>
14 #include <dune/common/propertymap.hh>
64 typedef typename M::block_type
Weight;
116 typedef typename conditional<
isMutable && C::mutableMatrix,
typename Matrix::row_type::Iterator,
117 typename Matrix::row_type::ConstIterator>::type
123 typedef typename conditional<
isMutable && C::mutableMatrix,
typename M::block_type,
124 const typename M::block_type>::type
152 typedef typename conditional<is_same<C, typename remove_const<C>::type>::value && C::mutableMatrix,
153 typename M::block_type,
const typename M::block_type>::type
177 VertexDescriptor
target()
const;
180 VertexDescriptor
source()
const;
190 VertexDescriptor source_;
199 EdgeDescriptor edge_;
262 typedef typename conditional<is_same<C, typename remove_const<C>::type>::value && C::mutableMatrix,
263 typename M::block_type,
const typename M::block_type>::type
272 const VertexDescriptor&
operator*()
const;
290 VertexDescriptor current_;
328 VertexIterator
begin();
334 VertexIterator
end();
340 ConstVertexIterator
begin()
const;
346 ConstVertexIterator
end()
const;
354 EdgeIterator
beginEdges(
const VertexDescriptor& source);
362 EdgeIterator
endEdges(
const VertexDescriptor& source);
371 ConstEdgeIterator
beginEdges(
const VertexDescriptor& source)
const;
379 ConstEdgeIterator
endEdges(
const VertexDescriptor& source)
const;
391 const Matrix&
matrix()
const;
417 EdgeDescriptor
findEdge(
const VertexDescriptor& source,
418 const VertexDescriptor& target)
const;
424 EdgeDescriptor* start_;
439 template<
class G,
class T>
473 : firstEdge_(firstEdge)
478 : firstEdge_(emap.firstEdge_)
483 return edge-firstEdge_;
487 EdgeDescriptor firstEdge_;
502 class EdgeIterator :
public RandomAccessIteratorFacade<EdgeIterator,const EdgeDescriptor>
536 const VertexDescriptor&
target()
const;
539 const VertexDescriptor&
source()
const;
545 VertexDescriptor source_;
550 EdgeDescriptor edge_;
557 :
public ForwardIteratorFacade<VertexIterator,const VertexDescriptor>
567 const VertexDescriptor&
end);
608 VertexDescriptor current_;
610 VertexDescriptor end_;
627 ConstVertexIterator
begin()
const;
633 ConstVertexIterator
end()
const;
641 ConstEdgeIterator
beginEdges(
const VertexDescriptor& source)
const;
649 ConstEdgeIterator
endEdges(
const VertexDescriptor& source)
const;
674 EdgeDescriptor
findEdge(
const VertexDescriptor& source,
675 const VertexDescriptor& target)
const;
683 SubGraph(
const Graph& graph,
const T& excluded);
694 std::size_t noVertices_;
696 VertexDescriptor endVertex_;
703 VertexDescriptor maxVertex_;
705 VertexDescriptor* edges_;
707 std::ptrdiff_t* start_;
709 std::ptrdiff_t* end_;
719 template<
class G,
class VP,
class VM=IdentityMap>
771 EdgeIterator
beginEdges(
const VertexDescriptor& source);
778 EdgeIterator
endEdges(
const VertexDescriptor& source);
785 ConstEdgeIterator
beginEdges(
const VertexDescriptor& source)
const;
792 ConstEdgeIterator
endEdges(
const VertexDescriptor& source)
const;
797 :
public conditional<is_same<typename remove_const<C>::type,
799 typename Graph::VertexIterator,
800 typename Graph::ConstVertexIterator>::type
808 typedef typename conditional<is_same<typename remove_const<C>::type,
810 typename Graph::VertexIterator,
811 typename Graph::ConstVertexIterator>::type
817 typedef typename conditional<is_same<typename remove_const<C>::type,
819 typename Graph::EdgeIterator,
820 typename Graph::ConstEdgeIterator>::type
851 typename conditional<is_same<C,typename remove_const<C>::type>::value,
853 const VertexProperties&>::type
861 EdgeIterator
begin() const;
868 EdgeIterator
end() const;
931 const Graph&
graph() const;
967 std::vector<VertexProperties> vertexProperties_;
974 template<
class G,
class VP,
class EP,
class VM=IdentityMap,
class EM=IdentityMap>
1032 :
public conditional<is_same<typename remove_const<C>::type,
1034 typename Graph::EdgeIterator,
1035 typename Graph::ConstEdgeIterator>::type
1044 typedef typename conditional<is_same<typename remove_const<C>::type,
1046 typename Graph::EdgeIterator,
1047 typename Graph::ConstEdgeIterator>::type
1077 typename conditional<is_same<C,typename remove_const<C>::type>::value,
1079 const EdgeProperties&>::type
1094 EdgeProperties,VM,EM> > EdgeIterator;
1101 EdgeProperties,VM,EM> > ConstEdgeIterator;
1108 EdgeIterator
beginEdges(const VertexDescriptor& source);
1115 EdgeIterator
endEdges(const VertexDescriptor& source);
1122 ConstEdgeIterator
beginEdges(const VertexDescriptor& source) const;
1129 ConstEdgeIterator
endEdges(const VertexDescriptor& source) const;
1134 :
public conditional<is_same<typename remove_const<C>::type,
1136 typename Graph::VertexIterator,
1137 typename Graph::ConstVertexIterator>::type
1145 typedef typename conditional<is_same<typename remove_const<C>::type,
1147 typename Graph::VertexIterator,
1148 typename Graph::ConstVertexIterator>::type
1179 typename conditional<is_same<C,typename remove_const<C>::type>::value,
1181 const VertexProperties&>::type
1263 EdgeDescriptor findEdge(const VertexDescriptor& source,
1264 const VertexDescriptor& target)
1266 return graph_.findEdge(source,target);
1274 EdgeProperties& getEdgeProperties(
const EdgeDescriptor& edge);
1282 const EdgeProperties& getEdgeProperties(
const EdgeDescriptor& edge)
const;
1290 EdgeProperties& getEdgeProperties(
const VertexDescriptor& source,
1291 const VertexDescriptor& target);
1299 const EdgeProperties& getEdgeProperties(
const VertexDescriptor& source,
1300 const VertexDescriptor& target)
const;
1306 const Graph&
graph()
const;
1333 const EdgeMap& emap=EdgeMap());
1344 std::vector<VertexProperties> vertexProperties_;
1348 std::vector<EdgeProperties> edgeProperties_;
1357 template<
typename G>
1395 return graph_->getVertexProperties(vertex);
1405 template<
typename G>
1420 typedef typename G::EdgeDescriptor
Edge;
1442 return graph_->getEdgeProperties(edge);
1459 template<
class G,
class V>
1460 int visitNeighbours(
const G& graph,
const typename G::VertexDescriptor& vertex,
1469 if(matrix_.N()!=matrix_.M())
1470 DUNE_THROW(
ISTLError,
"Matrix has to have as many columns as rows!");
1472 start_ =
new EdgeDescriptor[matrix_.N()+1];
1474 typedef typename M::ConstIterator Iterator;
1475 Iterator
row = matrix_.begin();
1476 start_[row.index()] = 0;
1478 for(Iterator row=matrix_.begin(); row != matrix_.end(); ++
row)
1479 start_[row.index()+1] = start_[row.index()] + row->size();
1491 return start_[matrix_.N()];
1503 return matrix_.N()-1;
1507 typename MatrixGraph<M>::EdgeDescriptor
1509 const VertexDescriptor& target)
const
1511 typename M::ConstColIterator found =matrix_[source].find(target);
1512 if(found == matrix_[source].end())
1513 return std::numeric_limits<EdgeDescriptor>::max();
1514 std::size_t offset = found.offset();
1518 assert(offset<noEdges());
1520 return start_[source]+offset;
1538 MatrixGraph<M>::EdgeIteratorT<C>::EdgeIteratorT(
const VertexDescriptor& source,
const ColIterator& block,
1539 const ColIterator& end,
const EdgeDescriptor& edge)
1540 : source_(source), block_(block), blockEnd_(end), edge_(edge)
1542 if(block_!=blockEnd_ && block_.index() == source_) {
1550 MatrixGraph<M>::EdgeIteratorT<C>::EdgeIteratorT(
const ColIterator& block)
1557 MatrixGraph<M>::EdgeIteratorT<C>::EdgeIteratorT(
const EdgeIteratorT<C1>& other)
1558 : source_(other.source_), block_(other.block_), blockEnd_(other.blockEnd_), edge_(other.edge_)
1564 inline typename MatrixGraph<M>::template EdgeIteratorT<C>::WeightType&
1565 MatrixGraph<M>::EdgeIteratorT<C>::weight()
const
1572 inline typename MatrixGraph<M>::template EdgeIteratorT<C>& MatrixGraph<M>::EdgeIteratorT<C>::operator++()
1577 if(block_!=blockEnd_ && block_.index() == source_) {
1587 inline bool MatrixGraph<M>::EdgeIteratorT<C>::operator!=(
const typename MatrixGraph<M>::template EdgeIteratorT<
typename remove_const<C>::type>& other)
const
1589 return block_!=other.block_;
1594 inline bool MatrixGraph<M>::EdgeIteratorT<C>::operator!=(
const typename MatrixGraph<M>::template EdgeIteratorT<
const typename remove_const<C>::type>& other)
const
1596 return block_!=other.block_;
1601 inline bool MatrixGraph<M>::EdgeIteratorT<C>::operator==(
const typename MatrixGraph<M>::template EdgeIteratorT<
typename remove_const<C>::type>& other)
const
1603 return block_==other.block_;
1608 inline bool MatrixGraph<M>::EdgeIteratorT<C>::operator==(
const typename MatrixGraph<M>::template EdgeIteratorT<
const typename remove_const<C>::type>& other)
const
1610 return block_==other.block_;
1615 inline typename MatrixGraph<M>::VertexDescriptor MatrixGraph<M>::EdgeIteratorT<C>::target()
const
1617 return block_.index();
1622 inline typename MatrixGraph<M>::VertexDescriptor MatrixGraph<M>::EdgeIteratorT<C>::source()
const
1629 inline const typename MatrixGraph<M>::EdgeDescriptor& MatrixGraph<M>::EdgeIteratorT<C>::operator*()
const
1636 inline const typename MatrixGraph<M>::EdgeDescriptor* MatrixGraph<M>::EdgeIteratorT<C>::operator->()
const
1643 MatrixGraph<M>::VertexIteratorT<C>::VertexIteratorT(C* graph,
1644 const VertexDescriptor& current)
1645 : graph_(graph), current_(current)
1651 MatrixGraph<M>::VertexIteratorT<C>::VertexIteratorT(
const VertexDescriptor& current)
1657 MatrixGraph<M>::VertexIteratorT<C>::VertexIteratorT(
const VertexIteratorT<MutableContainer>& other)
1658 : graph_(other.graph_), current_(other.current_)
1663 inline bool MatrixGraph<M>::VertexIteratorT<C>::operator!=(
const VertexIteratorT<MutableContainer>& other)
const
1665 return current_ != other.current_;
1670 inline bool MatrixGraph<M>::VertexIteratorT<C>::operator!=(
const VertexIteratorT<ConstContainer>& other)
const
1672 return current_ != other.current_;
1678 inline bool MatrixGraph<M>::VertexIteratorT<C>::operator==(
const VertexIteratorT<MutableContainer>& other)
const
1680 return current_ == other.current_;
1685 inline bool MatrixGraph<M>::VertexIteratorT<C>::operator==(
const VertexIteratorT<ConstContainer>& other)
const
1687 return current_ == other.current_;
1692 inline typename MatrixGraph<M>::template VertexIteratorT<C>& MatrixGraph<M>::VertexIteratorT<C>::operator++()
1700 inline typename MatrixGraph<M>::template VertexIteratorT<C>::WeightType&
1701 MatrixGraph<M>::VertexIteratorT<C>::weight()
const
1703 return graph_->matrix()[current_][current_];
1708 inline const typename MatrixGraph<M>::VertexDescriptor&
1709 MatrixGraph<M>::VertexIteratorT<C>::operator*()
const
1716 inline typename MatrixGraph<M>::template EdgeIteratorT<C>
1719 return graph_->beginEdges(current_);
1724 inline typename MatrixGraph<M>::template EdgeIteratorT<C>
1727 return graph_->endEdges(current_);
1731 inline typename MatrixGraph<M>::template VertexIteratorT<MatrixGraph<M> >
1734 return VertexIterator(
this,0);
1738 inline typename MatrixGraph<M>::template VertexIteratorT<MatrixGraph<M> >
1741 return VertexIterator(matrix_.N());
1746 inline typename MatrixGraph<M>::template VertexIteratorT<const MatrixGraph<M> >
1749 return ConstVertexIterator(
this, 0);
1753 inline typename MatrixGraph<M>::template VertexIteratorT<const MatrixGraph<M> >
1756 return ConstVertexIterator(matrix_.N());
1760 inline typename MatrixGraph<M>::template EdgeIteratorT<MatrixGraph<M> >
1763 return EdgeIterator(source, matrix_.operator[](source).begin(),
1764 matrix_.operator[](source).end(), start_[source]);
1768 inline typename MatrixGraph<M>::template EdgeIteratorT<MatrixGraph<M> >
1771 return EdgeIterator(matrix_.operator[](source).end());
1776 inline typename MatrixGraph<M>::template EdgeIteratorT<const MatrixGraph<M> >
1779 return ConstEdgeIterator(source, matrix_.operator[](source).begin(),
1780 matrix_.operator[](source).end(), start_[source]);
1784 inline typename MatrixGraph<M>::template EdgeIteratorT<const MatrixGraph<M> >
1787 return ConstEdgeIterator(matrix_.operator[](source).end());
1791 template<
class G,
class T>
1793 const EdgeDescriptor& edge)
1794 : source_(source), edge_(edge)
1798 template<
class G,
class T>
1803 template<
class G,
class T>
1806 return EdgeIndexMap(edges_);
1809 template<
class G,
class T>
1812 return other.edge_==edge_;
1815 template<
class G,
class T>
1822 template<
class G,
class T>
1829 template<
class G,
class T>
1835 template<
class G,
class T>
1841 template<
class G,
class T>
1848 template<
class G,
class T>
1854 template<
class G,
class T>
1857 return other.edge_-edge_;
1860 template<
class G,
class T>
1862 const VertexDescriptor& current,
1863 const VertexDescriptor& end)
1864 : graph_(graph), current_(current), end_(end)
1867 typedef typename T::const_iterator Iterator;
1869 for(Iterator vertex = graph_->excluded_.begin();
1870 current_ != end_ && *vertex;
1873 assert(current_ == end_ || !graph_->excluded_[current_]);
1876 template<
class G,
class T>
1881 template<
class G,
class T>
1886 while(current_ != end_ && graph_->excluded_[current_])
1889 assert(current_ == end_ || !graph_->excluded_[current_]);
1893 template<
class G,
class T>
1896 return current_==other.current_;
1899 template<
class G,
class T>
1905 template<
class G,
class T>
1908 return graph_->beginEdges(current_);
1911 template<
class G,
class T>
1914 return graph_->endEdges(current_);
1917 template<
class G,
class T>
1920 return VertexIterator(
this, 0, endVertex_);
1924 template<
class G,
class T>
1927 return VertexIterator(endVertex_);
1931 template<
class G,
class T>
1934 return EdgeIterator(source, edges_+start_[source]);
1937 template<
class G,
class T>
1940 return EdgeIterator(edges_+end_[source]);
1943 template<
class G,
class T>
1949 template<
class G,
class T>
1955 template<
class G,
class T>
1961 template<
class G,
class T>
1963 const VertexDescriptor& target)
const
1965 const EdgeDescriptor edge = std::lower_bound(edges_+start_[source], edges_+end_[source], target);
1966 if(edge==edges_+end_[source] || *edge!=target)
1967 return std::numeric_limits<EdgeDescriptor>::max();
1972 template<
class G,
class T>
1980 template<
class G,
class T>
1982 : excluded_(excluded), noVertices_(0), endVertex_(0), maxVertex_(graph.
maxVertex())
1984 start_ =
new std::ptrdiff_t[graph.noVertices()];
1985 end_ =
new std::ptrdiff_t[graph.noVertices()];
1986 edges_ =
new VertexDescriptor[graph.noEdges()];
1988 VertexDescriptor* edge=edges_;
1990 typedef typename Graph::ConstVertexIterator Iterator;
1991 Iterator endVertex=graph.end();
1993 for(Iterator vertex = graph.begin(); vertex != endVertex; ++vertex)
1994 if(excluded_[*vertex])
1995 start_[*vertex]=end_[*vertex]=-1;
1998 endVertex_ = std::max(*vertex, endVertex_);
2000 start_[*vertex] = edge-edges_;
2002 typedef typename Graph::ConstEdgeIterator Iterator;
2003 Iterator endEdge = vertex.end();
2005 for(Iterator iter=vertex.begin(); iter!= endEdge; ++iter)
2006 if(!excluded[iter.target()]) {
2007 *edge = iter.target();
2011 end_[*vertex] = edge - edges_;
2014 std::sort(edges_+start_[*vertex], edge);
2016 noEdges_ = edge-edges_;
2020 template<
class G,
class V,
class VM>
2023 return graph_.noEdges();
2026 template<
class G,
class V,
class VM>
2027 inline typename VertexPropertiesGraph<G,V,VM>::EdgeIterator
2030 return graph_.beginEdges(source);
2033 template<
class G,
class V,
class VM>
2034 inline typename VertexPropertiesGraph<G,V,VM>::EdgeIterator
2037 return graph_.endEdges(source);
2040 template<
class G,
class V,
class VM>
2041 typename VertexPropertiesGraph<G,V,VM>::ConstEdgeIterator
2044 return graph_.beginEdges(source);
2047 template<
class G,
class V,
class VM>
2048 typename VertexPropertiesGraph<G,V,VM>::ConstEdgeIterator
2051 return graph_.endEdges(source);
2054 template<
class G,
class V,
class VM>
2056 VertexPropertiesGraph<G,V,VM>::VertexIteratorT<C>
2057 ::VertexIteratorT(
const Father& iter,
2059 : Father(iter), graph_(graph)
2062 template<
class G,
class V,
class VM>
2064 VertexPropertiesGraph<G,V,VM>::VertexIteratorT<C>
2065 ::VertexIteratorT(
const Father& iter)
2069 template<
class G,
class V,
class VM>
2072 VertexPropertiesGraph<G,V,VM>::VertexIteratorT<C>
2073 ::VertexIteratorT(
const VertexIteratorT<C1>& other)
2074 : Father(other), graph_(other.graph_)
2077 template<
class G,
class V,
class VM>
2079 typename conditional<is_same<C,typename remove_const<C>::type>::value,
2081 inline VertexPropertiesGraph<G,V,VM>::VertexIteratorT<C>::properties()
const
2083 return graph_->getVertexProperties(Father::operator*());
2086 template<
class G,
class V,
class VM>
2088 typename conditional<is_same<typename remove_const<C>::type,
2090 typename G::EdgeIterator,
2091 typename G::ConstEdgeIterator>::type
2094 return graph_->beginEdges(Father::operator*());
2097 template<
class G,
class V,
class VM>
2099 typename conditional<is_same<typename remove_const<C>::type,
2101 typename G::EdgeIterator,
2102 typename G::ConstEdgeIterator>::type
2105 return graph_->endEdges(Father::operator*());
2108 template<
class G,
class V,
class VM>
2111 return VertexIterator(graph_.begin(),
this);
2114 template<
class G,
class V,
class VM>
2117 return VertexIterator(graph_.end());
2121 template<
class G,
class V,
class VM>
2124 return ConstVertexIterator(graph_.begin(),
this);
2127 template<
class G,
class V,
class VM>
2130 return ConstVertexIterator(graph_.end());
2133 template<
class G,
class V,
class VM>
2136 return vertexProperties_[vmap_[vertex]];
2139 template<
class G,
class V,
class VM>
2142 return vertexProperties_[vmap_[vertex]];
2145 template<
class G,
class V,
class VM>
2151 template<
class G,
class V,
class VM>
2154 return graph_.noVertices();
2158 template<
class G,
class V,
class VM>
2161 return graph_.maxVertex();
2164 template<
class G,
class V,
class VM>
2166 : graph_(graph), vmap_(vmap), vertexProperties_(vmap_[graph_.maxVertex()+1], V())
2169 template<
class G,
class V,
class E,
class VM,
class EM>
2171 PropertiesGraph<G,V,E,VM,EM>::EdgeIteratorT<C>::EdgeIteratorT(
const Father& iter,
2173 : Father(iter), graph_(graph)
2176 template<
class G,
class V,
class E,
class VM,
class EM>
2178 PropertiesGraph<G,V,E,VM,EM>::EdgeIteratorT<C>::EdgeIteratorT(
const Father& iter)
2182 template<
class G,
class V,
class E,
class VM,
class EM>
2185 PropertiesGraph<G,V,E,VM,EM>::EdgeIteratorT<C>::EdgeIteratorT(
const EdgeIteratorT<C1>& other)
2186 : Father(other), graph_(other.graph_)
2190 template<
class G,
class V,
class E,
class VM,
class EM>
2193 return graph_.noEdges();
2196 template<
class G,
class V,
class E,
class VM,
class EM>
2198 inline typename conditional<is_same<C,typename remove_const<C>::type>::value,E&,
const E&>::type
2199 PropertiesGraph<G,V,E,VM,EM>::EdgeIteratorT<C>::properties()
const
2201 return graph_->getEdgeProperties(Father::operator*());
2204 template<
class G,
class V,
class E,
class VM,
class EM>
2205 inline typename PropertiesGraph<G,V,E,VM,EM>::EdgeIterator
2208 return EdgeIterator(graph_.beginEdges(source),
this);
2211 template<
class G,
class V,
class E,
class VM,
class EM>
2212 inline typename PropertiesGraph<G,V,E,VM,EM>::EdgeIterator
2215 return EdgeIterator(graph_.endEdges(source));
2218 template<
class G,
class V,
class E,
class VM,
class EM>
2219 typename PropertiesGraph<G,V,E,VM,EM>::ConstEdgeIterator
2222 return ConstEdgeIterator(graph_.beginEdges(source),
this);
2225 template<
class G,
class V,
class E,
class VM,
class EM>
2226 typename PropertiesGraph<G,V,E,VM,EM>::ConstEdgeIterator
2229 return ConstEdgeIterator(graph_.endEdges(source));
2232 template<
class G,
class V,
class E,
class VM,
class EM>
2234 PropertiesGraph<G,V,E,VM,EM>::VertexIteratorT<C>
2235 ::VertexIteratorT(
const Father& iter,
2237 : Father(iter), graph_(graph)
2240 template<
class G,
class V,
class E,
class VM,
class EM>
2242 PropertiesGraph<G,V,E,VM,EM>::VertexIteratorT<C>
2243 ::VertexIteratorT(
const Father& iter)
2247 template<
class G,
class V,
class E,
class VM,
class EM>
2250 PropertiesGraph<G,V,E,VM,EM>::VertexIteratorT<C>
2251 ::VertexIteratorT(
const VertexIteratorT<C1>& other)
2252 : Father(other), graph_(other.graph_)
2255 template<
class G,
class V,
class E,
class VM,
class EM>
2257 inline typename conditional<is_same<C,typename remove_const<C>::type>::value,
2259 PropertiesGraph<G,V,E,VM,EM>::VertexIteratorT<C>::properties()
const
2261 return graph_->getVertexProperties(Father::operator*());
2264 template<
class G,
class V,
class E,
class VM,
class EM>
2266 inline typename PropertiesGraph<G,V,E,VM,EM>::template EdgeIteratorT<C>
2269 return graph_->beginEdges(Father::operator*());
2272 template<
class G,
class V,
class E,
class VM,
class EM>
2274 inline typename PropertiesGraph<G,V,E,VM,EM>::template EdgeIteratorT<C>
2277 return graph_->endEdges(Father::operator*());
2280 template<
class G,
class V,
class E,
class VM,
class EM>
2283 return VertexIterator(graph_.begin(),
this);
2286 template<
class G,
class V,
class E,
class VM,
class EM>
2289 return VertexIterator(graph_.end());
2293 template<
class G,
class V,
class E,
class VM,
class EM>
2296 return ConstVertexIterator(graph_.begin(),
this);
2299 template<
class G,
class V,
class E,
class VM,
class EM>
2302 return ConstVertexIterator(graph_.end());
2305 template<
class G,
class V,
class E,
class VM,
class EM>
2308 return vertexProperties_[vmap_[vertex]];
2311 template<
class G,
class V,
class E,
class VM,
class EM>
2314 return vertexProperties_[vmap_[vertex]];
2317 template<
class G,
class V,
class E,
class VM,
class EM>
2320 return edgeProperties_[emap_[edge]];
2323 template<
class G,
class V,
class E,
class VM,
class EM>
2326 return edgeProperties_[emap_[edge]];
2329 template<
class G,
class V,
class E,
class VM,
class EM>
2331 const VertexDescriptor& target)
2333 return getEdgeProperties(graph_.findEdge(source,target));
2336 template<
class G,
class V,
class E,
class VM,
class EM>
2338 const VertexDescriptor& target)
const
2340 return getEdgeProperties(graph_.findEdge(source,target));
2343 template<
class G,
class V,
class E,
class VM,
class EM>
2349 template<
class G,
class V,
class E,
class VM,
class EM>
2352 return graph_.noVertices();
2356 template<
class G,
class V,
class E,
class VM,
class EM>
2359 return graph_.maxVertex();
2362 template<
class G,
class V,
class E,
class VM,
class EM>
2364 : graph_(graph), vmap_(vmap), vertexProperties_(vmap_[graph_.maxVertex()+1], V()),
2365 emap_(emap), edgeProperties_(graph_.noEdges(), E())
2368 template<
class G,
class V>
2369 inline int visitNeighbours(
const G& graph,
const typename G::VertexDescriptor& vertex,
2372 typedef typename G::ConstEdgeIterator iterator;
2373 const iterator end = graph.endEdges(vertex);
2375 for(iterator edge = graph.beginEdges(vertex); edge != end; ++edge, ++noNeighbours)
2377 return noNeighbours;
VertexIterator begin()
Get an iterator over the vertices.
VertexDescriptor maxVertex() const
Get the maximal vertex descriptor.
EdgeIterator beginEdges(const VertexDescriptor &source)
Get an iterator over the edges starting at a vertex.
EdgeIteratorT< C > & operator++()
preincrement operator.
const EdgeDescriptor & operator*() const
Get the edge descriptor.
std::ptrdiff_t distanceTo(const EdgeIterator &other) const
conditional< is_same< C, typename remove_const< C >::type >::value &&C::mutableMatrix, typename M::block_type, const typename M::block_type >::type WeightType
Definition: graph.hh:264
VertexIteratorT< MatrixGraph< Matrix > > VertexIterator
The mutable vertex iterator type.
Definition: graph.hh:311
VertexIteratorT(C *graph, const VertexDescriptor ¤t)
Constructor.
remove_const< M >::type MutableMatrix
The mutable type of the matrix we are a graph for.
Definition: graph.hh:59
bool equals(const EdgeIterator &other) const
Equality operator.
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.
conditional< is_same< typename remove_const< C >::type, C >::value, typename Graph::EdgeIterator, typename Graph::ConstEdgeIterator >::type Father
The father class.
Definition: graph.hh:1048
EdgeIteratorT(const VertexDescriptor &source, const ColIterator &block, const ColIterator &end, const EdgeDescriptor &edge)
Constructor.
VertexDescriptor * EdgeDescriptor
Definition: graph.hh:459
EdgeIterator endEdges(const VertexDescriptor &source)
Get the mutable edge iterator over edges starting at a vertex.
Graph::EdgeDescriptor EdgeDescriptor
The edge descritor.
Definition: graph.hh:736
conditional< is_same< C, typename remove_const< C >::type >::value &&C::mutableMatrix, typename M::block_type, const typename M::block_type >::type WeightType
Definition: graph.hh:154
const VertexDescriptor & target() const
The index of the target vertex of the current edge.
Row row
Definition: matrixmatrix.hh:345
remove_const< C >::type MutableContainer
The mutable type of the container type.
Definition: graph.hh:99
Definition: basearray.hh:19
const VertexDescriptor & source() const
The index of the source vertex of the current edge.
M::block_type Weight
The type of the weights.
Definition: graph.hh:64
The edge iterator of the graph.
Definition: graph.hh:502
conditional< isMutable &&C::mutableMatrix, typename Matrix::row_type::Iterator, typename Matrix::row_type::ConstIterator >::type ColIterator
The column iterator of the matrix we use.
Definition: graph.hh:118
VM VertexMap
The type of the map for converting the VertexDescriptor to std::size_t.
Definition: graph.hh:1009
VertexIterator begin()
Get an iterator over the vertices.
VertexIterator ConstVertexIterator
The constant vertex iterator type.
Definition: graph.hh:621
Matrix & matrix()
Get the underlying matrix.
ReadablePropertyMapTag Category
Definition: graph.hh:470
VertexIterator end()
Get an iterator over the vertices.
const Graph & graph() const
Get the graph the properties are attached to.
derive error class from the base class in common
Definition: istlexception.hh:16
std::size_t noVertices() const
Get the number of vertices in the graph.
Graph::VertexDescriptor VertexDescriptor
The vertex descriptor.
Definition: graph.hh:731
Attaches properties to the edges and vertices of a graph.
Definition: graph.hh:975
VertexDescriptor target() const
The index of the target vertex of the current edge.
GraphEdgePropertiesSelector()
Default constructor.
Definition: graph.hh:1432
EP EdgeProperties
The type of the properties of the edges;.
Definition: graph.hh:1014
EdgeIterator beginEdges(const VertexDescriptor &source)
Get the mutable edge iterator over edges starting at a vertex.
VertexProperties & operator[](const Vertex &vertex) const
Get the properties associated to a vertex.
Definition: graph.hh:1393
VertexProperties & getVertexProperties(const VertexDescriptor &vertex)
Get the properties associated with a vertex.
VP VertexProperties
The type of the properties of the vertices.
Definition: graph.hh:741
std::size_t noVertices() const
Get the number of vertices in the graph.
const remove_const< C >::type ConstContainer
The constant type of the container type.
Definition: graph.hh:103
std::size_t noEdges() const
Get the number of edges in the graph.
const Graph & graph() const
Get the graph the properties are attached to.
The (undirected) graph of a matrix.
Definition: graph.hh:48
VertexIterator & increment()
Preincrement operator.
ConstVertexIterator end() const
Get an iterator over the vertices.
EdgeIterator & advance(std::ptrdiff_t n)
EdgeIndexMap(const EdgeDescriptor &firstEdge)
Definition: graph.hh:472
whether C is mutable.
Definition: graph.hh:223
bool equals(const VertexIterator &other) const
Equality iterator.
EdgeIterator beginEdges(const VertexDescriptor &source)
Get the mutable edge iterator over edges starting at a vertex.
Graph::VertexDescriptor VertexDescriptor
The vertex descriptor.
Definition: graph.hh:457
EdgeIterator begin() const
Get an iterator over the edges starting from the current vertex.
T Excluded
Random access container providing information about which vertices are excluded.
Definition: graph.hh:452
GraphVertexPropertiesSelector()
Default constructor.
Definition: graph.hh:1384
EdgeIterator(const VertexDescriptor &source, const EdgeDescriptor &edge)
Constructor.
VertexIterator begin()
Get an iterator over the vertices.
const EdgeDescriptor & dereference() const
The descriptor of the current edge.
conditional< is_same< typename remove_const< C >::type, C >::value, typename Graph::VertexIterator, typename Graph::ConstVertexIterator >::type Father
The father class.
Definition: graph.hh:812
EdgeIteratorT< C > end() const
Get an iterator over all edges starting at the current vertex.
VertexIteratorT< C > & operator++()
Move to the next vertex.
An index map for mapping the edges to indices.
Definition: graph.hh:467
G Graph
The graph we attach properties to.
Definition: graph.hh:726
const remove_const< C >::type ConstContainer
The constant type of the container type.
Definition: graph.hh:216
EdgeIteratorT< const MatrixGraph< Matrix > > ConstEdgeIterator
The constant edge iterator type.
Definition: graph.hh:296
EdgeIndexMap(const EdgeIndexMap &emap)
Protect copy construction.
Definition: graph.hh:477
const VertexDescriptor & dereference() const
Get the descriptor of the current vertex.
conditional< is_same< C, typename remove_const< C >::type >::value, VertexProperties &, const VertexProperties & >::type properties() const
Get the properties of the current Vertex.
conditional< isMutable &&C::mutableMatrix, typename M::block_type, const typename M::block_type >::type Weight
The matrix block type we use as weights.
Definition: graph.hh:125
EdgeIterator begin() const
Get an iterator over all edges starting at the current vertex.
Graph::VertexDescriptor VertexDescriptor
The vertex descriptor.
Definition: graph.hh:986
ConstEdgeIterator endEdges(const VertexDescriptor &source) const
Get an iterator over the edges starting at a vertex.
The vertex iterator of the graph.
Definition: graph.hh:556
EdgeProperties & getEdgeProperties(const EdgeDescriptor &edge)
Get the properties associated with a edge.
Definition: graph.hh:1031
bool operator!=(const EdgeIteratorT< typename remove_const< C >::type > &other) const
Inequality operator.
VertexPropertiesGraph(Graph &graph, const VertexMap vmap=VertexMap())
Constructor.
WeightType & weight() const
Access the weight of the vertex.
std::size_t noVertices() const
Get the number of vertices in the graph.
std::size_t noEdges() const
Get the number of edges in the graph.
G Graph
The type of the graph with internal properties.
Definition: graph.hh:1364
GraphVertexPropertiesSelector(G &g)
Constructor.
Definition: graph.hh:1378
Graph::EdgeIterator EdgeIterator
The type of the mutable edge iterator.
Definition: graph.hh:759
EdgeIterator end() const
Get an iterator over all edges starting at the current vertex.
const EdgeDescriptor * operator->() const
Get the edge descriptor.
The vertex iterator type of the graph.
Definition: graph.hh:206
VertexDescriptor maxVertex() const
Get the maximal vertex descriptor.
EdgeIterator ConstEdgeIterator
The constant edge iterator type.
Definition: graph.hh:616
VertexIterator end()
Get an iterator over the vertices.
G Graph
The type of the graph we are a sub graph for.
Definition: graph.hh:446
M::size_type VertexDescriptor
The vertex descriptor.
Definition: graph.hh:71
EM EdgeMap
The type of the map for converting the EdgeDescriptor to std::size_t.
Definition: graph.hh:1028
EdgeProperties & operator[](const Edge &edge) const
Get the properties associated to a vertex.
Definition: graph.hh:1440
std::size_t operator[](const EdgeDescriptor &edge) const
Definition: graph.hh:481
Wrapper to access the internal edge properties of a graph via operator[]()
Definition: graph.hh:1358
EdgeIterator & decrement()
Preincrement operator.
EdgeIterator end() const
Get an iterator over the edges starting from the current vertex.
bool operator!=(const VertexIteratorT< ConstContainer > &other) const
Inequality operator.
A subgraph of a graph.
Definition: graph.hh:440
G::EdgeProperties EdgeProperties
The type of the vertex properties.
Definition: graph.hh:1416
std::size_t noEdges() const
Get the number of edges in the graph.
std::size_t noEdges() const
Get the number of edges in the graph.
conditional< is_same< typename remove_const< C >::type, C >::value, typename Graph::VertexIterator, typename Graph::ConstVertexIterator >::type Father
The father class.
Definition: graph.hh:1149
VertexDescriptor source() const
The index of the source vertex of the current edge.
VM VertexMap
The type of the map for converting the VertexDescriptor to std::size_t.
Definition: graph.hh:754
VertexDescriptor maxVertex() const
Get the maximal vertex descriptor.
MatrixGraph(Matrix &matrix)
Constructor.
bool operator==(const VertexIteratorT< ConstContainer > &other) const
Equality operator.
EdgeIterator & increment()
Preincrement operator.
Graph::EdgeDescriptor EdgeDescriptor
The edge descritor.
Definition: graph.hh:991
G::VertexDescriptor Vertex
The vertex descriptor.
Definition: graph.hh:1372
~MatrixGraph()
Destructor.
EdgeIndexMap getEdgeIndexMap()
Get an edge index map for the graph.
VertexIterator(const SubGraph< G, T > *graph, const VertexDescriptor ¤t, const VertexDescriptor &end)
Constructor.
EdgeDescriptor findEdge(const VertexDescriptor &source, const VertexDescriptor &target) const
Find the descriptor of an edge.
EdgeIteratorT< C > begin() const
Get an iterator over all edges starting at the current vertex.
G::VertexProperties VertexProperties
The type of the vertex properties.
Definition: graph.hh:1368
EdgeIteratorT< MatrixGraph< Matrix > > EdgeIterator
The mutable edge iterator type.
Definition: graph.hh:301
int visitNeighbours(const G &graph, const typename G::VertexDescriptor &vertex, V &visitor)
Visit all neighbour vertices of a vertex in a graph.
G Graph
The type of the graph with internal properties.
Definition: graph.hh:1412
bool operator==(const EdgeIteratorT< typename remove_const< C >::type > &other) const
Equality operator.
Graph::ConstEdgeIterator ConstEdgeIterator
The type of the constant edge iterator.
Definition: graph.hh:764
ConstVertexIterator begin() const
Get an iterator over the vertices.
std::ptrdiff_t EdgeDescriptor
The edge descriptor.
Definition: graph.hh:78
EdgeDescriptor findEdge(const VertexDescriptor &source, const VertexDescriptor &target) const
Find the descriptor of an edge.
VertexIteratorT< const MatrixGraph< Matrix > > ConstVertexIterator
The constant vertex iterator type.
Definition: graph.hh:306
VertexProperties & getVertexProperties(const VertexDescriptor &vertex)
Get the properties associated with a vertex.
VP VertexProperties
The type of the properties of the vertices.
Definition: graph.hh:996
VertexDescriptor maxVertex() const
Get the maximal vertex descriptor.
G Graph
The graph we attach properties to.
Definition: graph.hh:981
EdgeIterator endEdges(const VertexDescriptor &source)
Get the mutable edge iterator over edges starting at a vertex.
VertexIterator end()
Get an iterator over the vertices.
Attaches properties to the vertices of a graph.
Definition: graph.hh:720
Iterator over all edges starting from a vertex.
Definition: graph.hh:92
WeightType & weight() const
Access the edge weight.
EdgeIterator endEdges(const VertexDescriptor &source)
Get an iterator over the edges starting at a vertex.
G::EdgeDescriptor Edge
The edge descriptor.
Definition: graph.hh:1420
const VertexDescriptor & operator*() const
Get the descriptor of the current vertex.
GraphEdgePropertiesSelector(G &g)
Constructor.
Definition: graph.hh:1426
remove_const< C >::type MutableContainer
The mutable type of the container type.
Definition: graph.hh:212
M Matrix
The type of the matrix we are a graph for.
Definition: graph.hh:54
PropertiesGraph(Graph &graph, const VertexMap &vmap=VertexMap(), const EdgeMap &emap=EdgeMap())
Constructor.
Definition: graph.hh:1133
SubGraph(const Graph &graph, const T &excluded)
Constructor.
whether C is mutable.
Definition: graph.hh:110
Wrapper to access the internal vertex properties of a graph via operator[]()
Definition: graph.hh:1406