]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/graph/include/boost/graph/lookup_edge.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / graph / include / boost / graph / lookup_edge.hpp
1 //=======================================================================
2 // Copyright 2009 Trustees of Indiana University
3 // Author: Jeremiah Willcock
4 //
5 // Distributed under the Boost Software License, Version 1.0. (See
6 // accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8 //=======================================================================
9
10 #ifndef BOOST_GRAPH_LOOKUP_EDGE_HPP
11 #define BOOST_GRAPH_LOOKUP_EDGE_HPP
12
13 #include <utility>
14 #include <boost/config.hpp>
15 #include <boost/utility/enable_if.hpp>
16 #include <boost/graph/graph_traits.hpp>
17
18 // lookup_edge: a function that acts like edge() but falls back to out_edges()
19 // and a search when edge() is not provided.
20
21 namespace boost {
22
23 template <typename Graph>
24 std::pair<typename boost::graph_traits<Graph>::edge_descriptor, bool>
25 lookup_edge(typename boost::graph_traits<Graph>::vertex_descriptor src,
26 typename boost::graph_traits<Graph>::vertex_descriptor tgt,
27 const Graph& g,
28 typename boost::enable_if<is_adjacency_matrix<Graph>, int>::type = 0) {
29 return edge(src, tgt, g);
30 }
31
32 template <typename Graph>
33 std::pair<typename boost::graph_traits<Graph>::edge_descriptor, bool>
34 lookup_edge(typename boost::graph_traits<Graph>::vertex_descriptor src,
35 typename boost::graph_traits<Graph>::vertex_descriptor tgt,
36 const Graph& g,
37 typename boost::disable_if<is_adjacency_matrix<Graph>, int>::type = 0) {
38 typedef typename boost::graph_traits<Graph>::out_edge_iterator it;
39 typedef typename boost::graph_traits<Graph>::edge_descriptor edesc;
40 std::pair<it, it> oe = out_edges(src, g);
41 for (; oe.first != oe.second; ++oe.first) {
42 edesc e = *oe.first;
43 if (target(e, g) == tgt) return std::make_pair(e, true);
44 }
45 return std::make_pair(edesc(), false);
46 }
47
48 }
49
50 #endif // BOOST_GRAPH_LOOKUP_EDGE_HPP