61 typedef typename std::iterator_traits<iterator>::value_type
value_type;
62 typedef typename std::iterator_traits<iterator>::reference
reference;
77 template <
typename Pair,
typename iterator>
83 template <
typename iterator>
89 template <
typename T>
inline T*
pointer(
const T&)
94 template <
typename Container>
95 std::pair<typename Container::iterator, typename Container::iterator>
make_range(Container& cont)
97 return std::make_pair(cont.begin(), cont.end());
100 template <
typename Container>
101 std::pair<
typename Container::const_iterator,
102 typename Container::const_iterator>
make_range(
const Container& cont)
104 return std::make_pair(cont.begin(), cont.end());
107 template <
typename Iterator> std::pair<Iterator, Iterator>
113 template <
typename Container>
114 std::pair<typename Container::reverse_iterator, typename Container::reverse_iterator>
117 return std::make_pair(cont.rbegin(), cont.rend());
120 template <
typename Container>
121 std::pair<typename Container::const_reverse_iterator, typename Container::const_reverse_iterator>
124 return std::make_pair(cont.rbegin(), cont.rend());
127 template <
typename Iterator>
128 std::pair<std::reverse_iterator<Iterator>, std::reverse_iterator<Iterator> >
131 typedef std::reverse_iterator<Iterator> reverse_it;
132 return make_pair(reverse_it(cont.second), reverse_it(cont.first));
161 template <
typename VertexContent,
typename EdgeContent = _EmptyEdgeContent>
204 typename neighborhood_t::iterator it;
217 template <
typename Iterator>
VVGraph(Iterator
begin, Iterator
end,
bool checkUnique =
true)
227 template <
typename Container>
VVGraph(
const Container& c,
bool checkUnique =
true)
233 struct single_neighborhood_t;
256 static_cast<EdgeContent&
>(*this) = EdgeContent();
264 static_cast<EdgeContent&
>(*this) =
static_cast<const EdgeContent&
>(copy);
284 && (
static_cast<const EdgeContent&
>(*this) ==
static_cast<const EdgeContent&
>(other));
350 typedef std::unordered_map<vertex_t, NeighborhoodPair*>
lookup_t;
408 typedef std::pair<const_neighbor_iterator, const_neighbor_iterator>
420 typedef std::pair<const_circ_neighbor_iterator, const_circ_neighbor_iterator>
543 const NeighborhoodPair* found = this->
findVertex(v);
545 return found->vertex;
833 return found->vertex;
854 return found->vertex;
1119 template <
typename VertexContainer>
VVGraph subgraph(
const VertexContainer& vertexes)
const;
1143 template <
typename Iterator>
1144 void insert(Iterator first, Iterator last,
bool checkUnique =
true);
1149 template <
typename Iterator>
1150 void insert(
const std::pair<Iterator, Iterator>& range,
bool checkUnique =
true);
1292 typedef search_result_t<const single_neighborhood_t, int_const_neighbor_iterator>
1308 typename neighborhood_t::iterator
findIterator(
const NeighborhoodPair* np);
1309 typename neighborhood_t::const_iterator
findIterator(
const NeighborhoodPair* np)
const;
1349 template <
typename VertexContent,
typename EdgeContent>
1352 if(neighborhood.size() == 0)
1354 typename neighborhood_t::iterator it;
1355 for(it = neighborhood.begin(); it != neighborhood.end(); ++it) {
1359 neighborhood.clear();
1365 template <
typename VertexContent,
typename EdgeContent>
1371 *it.
base() = neighborhood.back();
1372 neighborhood.pop_back();
1377 template <
typename VertexContent,
typename EdgeContent>
1381 if(eraseAllEdges(v)) {
1382 NeighborhoodPair* np = lookup[v];
1384 typename neighborhood_t::iterator it = this->findIterator(np);
1386 *it = neighborhood.back();
1387 neighborhood.pop_back();
1395 template <
typename VertexContent,
typename EdgeContent>
1398 if(neighborhood.size() == 0)
1400 for(
typename neighborhood_t::iterator it = neighborhood.begin(); it != neighborhood.end(); ++it)
1401 it->single_neighborhood.edges.clear();
1406 template <
typename VertexContent,
typename EdgeContent>
1409 NeighborhoodPair* it_found = this->findVertex(v);
1411 eraseAllEdges(it_found);
1418 template <
typename VertexContent,
typename EdgeContent>
1423 NeighborhoodPair* it_found = this->findVertex(v);
1424 edge_list_t& lst = it_found->single_neighborhood.edges;
1425 for(
typename edge_list_t::iterator it = lst.begin(); it != lst.end(); ++it)
1426 eraseEdge(it->target, v);
1428 np->single_neighborhood.edges.clear();
1433 template <
typename VertexContent,
typename EdgeContent>
1436 eraseAllEdges(*it_found.
base());
1440 template <
typename VertexContent,
typename EdgeContent>
1443 typename neighborhood_t::iterator it_found = this->findVertex(v);
1444 if(it_found != neighborhood.end()) {
1452 template <
typename VertexContent,
typename EdgeContent>
1456 it.
base()->single_neighborhood.edges.clear();
1461 template <
typename VertexContent,
typename EdgeContent>
1465 return lookup.count(v);
1469 template <
typename VertexContent,
typename EdgeContent>
1472 typename lookup_t::iterator it_found = lookup.end();
1474 it_found = lookup.find(v);
1475 if(!checkUnique or it_found == lookup.end()) {
1476 NeighborhoodPair* np =
new NeighborhoodPair(v);
1477 neighborhood.push_back(np);
1488 template <
typename VertexContent,
typename EdgeContent>
1489 template <
typename Iterator>
1492 insert(range.first, range.second, checkUnique);
1496 template <
typename VertexContent,
typename EdgeContent>
1497 template <
typename Iterator>
1501 for(Iterator it = first; it != last; ++it)
1504 for(Iterator it = first; it != last; ++it) {
1505 NeighborhoodPair* np =
new NeighborhoodPair(*it);
1506 neighborhood.push_back(np);
1514 template <
typename VertexContent,
typename EdgeContent>
1518 if(neighborhood.empty())
1519 return vertex_t::null;
1524 template <
typename VertexContent,
typename EdgeContent>
1528 typename neighborhood_t::const_iterator it = neighborhood.begin();
1529 std::advance(it, idx);
1530 return (*it)->vertex;
1534 template <
typename VertexContent,
typename EdgeContent>
1539 return vertex_t::null;
1540 const NeighborhoodPair* it_found = this->findVertex(v);
1541 if(not it_found || it_found->single_neighborhood.edges.empty())
1542 return vertex_t::null;
1543 const edge_list_t& lst = it_found->single_neighborhood.edges;
1544 return lst.front().target;
1548 template <
typename VertexContent,
typename EdgeContent>
1554 const NeighborhoodPair* it_found = this->findVertex(v);
1557 return it_found->single_neighborhood.edges.size();
1561 template <
typename VertexContent,
typename EdgeContent>
1566 const NeighborhoodPair* it_found = this->findVertex(v);
1569 return it_found->single_neighborhood.edges.empty();
1573 template <
typename VertexContent,
typename EdgeContent>
1577 return std::find(neighborhood.begin(), neighborhood.end(), np);
1581 template <
typename VertexContent,
typename EdgeContent>
1585 return std::find(neighborhood.begin(), neighborhood.end(), np);
1589 template <
typename VertexContent,
typename EdgeContent>
1593 typename lookup_t::const_iterator it_found = lookup.find(v);
1594 if(it_found != lookup.end())
1595 return it_found->second;
1600 template <
typename VertexContent,
typename EdgeContent>
1604 typename lookup_t::const_iterator it_found = lookup.find(v);
1605 if(it_found != lookup.end())
1606 return it_found->second;
1611 template <
typename VertexContent,
typename EdgeContent>
1615 if(v.
isNull() ||
n.isNull() || v ==
n)
1617 NeighborhoodPair* it_found = this->findVertex(v);
1620 edge_list_t& lst = it_found->single_neighborhood.edges;
1621 single_neighborhood_t* neighborhood = &it_found->single_neighborhood;
1622 for(
typename edge_list_t::iterator it = lst.begin(); it != lst.end(); ++it) {
1623 if(it->target ==
n) {
1631 template <
typename VertexContent,
typename EdgeContent>
1635 if(v.
isNull() ||
n.isNull() || v ==
n)
1637 const NeighborhoodPair* it_found = this->findVertex(v);
1640 const edge_list_t& lst = it_found->single_neighborhood.edges;
1641 const single_neighborhood_t* neighborhood = &it_found->single_neighborhood;
1642 for(
typename edge_list_t::const_iterator it = lst.begin(); it != lst.end(); ++it) {
1643 if(it->target ==
n) {
1651 template <
typename VertexContent,
typename EdgeContent>
1656 if(found.neighborhood)
1662 template <
typename VertexContent,
typename EdgeContent>
1667 if(found.neighborhood)
1673 template <
typename VertexContent,
typename EdgeContent>
1677 return eraseEdge(v, *pos);
1681 template <
typename VertexContent,
typename EdgeContent>
1685 return eraseEdge(v, pos.
base());
1689 template <
typename VertexContent,
typename EdgeContent>
1696 found.neighborhood->edges.erase(found.it);
1702 template <
typename VertexContent,
typename EdgeContent>
1705 return this->findVertex(v);
1709 template <
typename VertexContent,
typename EdgeContent>
1714 if(new_neighbor.
isNull() or (v == new_neighbor) or (neighbor == new_neighbor))
1721 found.it->target = new_neighbor;
1722 found.it->clear_edge();
1724 return edge_t(v.
id(), new_neighbor.
id(), &*found.it);
1728 template <
typename VertexContent,
typename EdgeContent>
1734 return vertex_t::null;
1735 typename edge_list_t::const_iterator it = found.it;
1736 const edge_list_t& lst = found.neighborhood->edges;
1737 for(
unsigned int i = 0; i <
n; ++i) {
1746 template <
typename VertexContent,
typename EdgeContent>
1752 return vertex_t::null;
1753 typename edge_list_t::const_iterator it = found.it;
1754 const edge_list_t& lst = found.neighborhood->edges;
1755 for(
unsigned int i = 0; i <
n; ++i) {
1756 if(it == lst.begin())
1764 template <
typename VertexContent,
typename EdgeContent>
1771 return edge_t(src.
id(), tgt.
id(), &*found.it);
1775 template <
typename VertexContent,
typename EdgeContent>
1786 template <
typename VertexContent,
typename EdgeContent>
1791 if(new_neighbor.
isNull() || v == new_neighbor)
1797 typename edge_list_t::iterator new_edge_it
1798 = found.neighborhood->edges.insert(found.it, neighbor_t(new_neighbor, EdgeContent()));
1800 return edge_t(v.
id(), new_neighbor.
id(), &*new_edge_it);
1804 template <
typename VertexContent,
typename EdgeContent>
1809 if(new_neighbor.
isNull() || v == new_neighbor)
1814 typename edge_list_t::iterator new_edge_it
1815 = found.neighborhood->edges.insert(found.it, neighbor_t(new_neighbor, EdgeContent()));
1817 return edge_t(v.
id(), new_neighbor.
id(), &*new_edge_it);
1821 template <
typename VertexContent,
typename EdgeContent>
1825 if(v.
isNull() || new_neighbor.
isNull() || v == new_neighbor)
1827 NeighborhoodPair* it_found = this->findVertex(v);
1830 edge_list_t& lst = it_found->single_neighborhood.edges;
1834 lst.push_back(neighbor_t(new_neighbor, EdgeContent()));
1836 return edge_t(v.
id(), new_neighbor.
id(), &lst.back());
1840 template <
typename VertexContent,
typename EdgeContent>
1847 const NeighborhoodPair* it_found = this->findVertex(v);
1850 const edge_list_t& lst = it_found->single_neighborhood.edges;
1857 template <
typename VertexContent,
typename EdgeContent>
1864 NeighborhoodPair* it_found = this->findVertex(v);
1867 edge_list_t& lst = it_found->single_neighborhood.edges;
1874 template <
typename VertexContent,
typename EdgeContent>
1884 const edge_list_t& lst = found.neighborhood->edges;
1891 template <
typename VertexContent,
typename EdgeContent>
1908 template <
typename VertexContent,
typename EdgeContent>
1909 template <
typename VertexContainer>
1913 typename VertexContainer::const_iterator it;
1916 for(it = verts.begin(); it != verts.end(); ++it) {
1919 const NeighborhoodPair* it_orign;
1920 typename neighborhood_t::iterator it_n;
1922 typename edge_list_t::const_iterator it_sn;
1925 const vertex_t& v = (*it_n)->vertex;
1927 it_orign = this->findVertex(v);
1928 const edge_list_t& orig_lst = it_orign->single_neighborhood.edges;
1929 edge_list_t& lst = (*it_n)->single_neighborhood.edges;
1933 for(it_sn = orig_lst.begin(); it_sn != orig_lst.end(); ++it_sn) {
1936 if(result.
contains(it_sn->target)) {
1939 lst.push_back(neighbor_t(it_sn->target, *it_sn));
1947 template <
typename VertexContent,
typename EdgeContent>
1954 template <
typename VertexContent,
typename EdgeContent>
1959 for(
typename neighborhood_t::const_iterator it = neighborhood.begin(); it != neighborhood.end(); ++it) {
1961 typename lookup_t::const_iterator it_found = other.
lookup.find(v1);
1962 if(it_found == other.
lookup.end())
1964 if(it->single_neighborhood.edges.empty()) {
1965 if(!it_found->single_neighborhood.single_neighborhood.edges.empty())
1968 const edge_list_t& lst = it->single_neighborhood.edges;
1969 const edge_list_t& olst = it_found->second->single_neighborhood.edges;
1970 if(lst.size() != olst.size())
1972 const vertex_t& v2 = lst.begin()->target;
1974 for(
typename edge_list_t::const_iterator it_olst = olst.begin(); it_olst != olst.end(); ++it_olst) {
1975 if(it_olst->target == v2) {
1977 for(
typename edge_list_t::const_iterator it_lst = lst.begin(); it_lst != lst.end(); ++it_lst) {
1978 if(it_lst->target != it_olst->target)
1981 if(it_olst == olst.end())
1982 it_olst = olst.begin();
1995 template <
typename VertexContent,
typename EdgeContent>
1998 typename neighborhood_t::iterator it;
1999 for(it = neighborhood.begin(); it != neighborhood.end(); ++it) {
2000 std::reverse((*it)->single_neighborhood.edges.begin(), (*it)->single_neighborhood.edges.end());
2006 template <
typename VertexContent,
typename EdgeContent>
2009 typename neighborhood_t::const_iterator it_o;
2010 typename neighborhood_t::iterator it;
2011 for(it = neighborhood.begin(); it != neighborhood.end(); ++it) {
2015 neighborhood.
clear();
2017 it = neighborhood.end();
2019 NeighborhoodPair* np = (*it_o)->copy();
2020 neighborhood.push_back(np);
2021 lookup[(*it_o)->vertex] = np;
2027 template <
typename VertexContent,
typename EdgeContent>
2031 lookup.swap(other.
lookup);
2035 template <
typename VertexContent,
typename EdgeContent>
2038 if(v <=
n or v <= m or
n == m or !
edge(v,
n) or !
edge(v, m) or !
edge(
n, m))
2045 template <
typename VertexContent,
typename EdgeContent>
2048 if(v <=
n or !
edge(v,
n))