2 //=======================================================================
3 // Copyright 1997, 1998, 1999, 2000 University of Notre Dame.
4 // Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek
6 // Distributed under the Boost Software License, Version 1.0. (See
7 // accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
9 //=======================================================================
11 #ifndef BOOST_GRAPH_DETAIL_EDGE_HPP
12 #define BOOST_GRAPH_DETAIL_EDGE_HPP
16 #include <boost/functional/hash.hpp>
22 template <typename Directed, typename Vertex>
26 inline edge_base(Vertex s, Vertex d)
27 : m_source(s), m_target(d) { }
32 template <typename Directed, typename Vertex>
33 class edge_desc_impl : public edge_base<Directed,Vertex> {
34 typedef edge_desc_impl self;
35 typedef edge_base<Directed,Vertex> Base;
37 typedef void property_type;
39 inline edge_desc_impl() : m_eproperty(0) {}
41 inline edge_desc_impl(Vertex s, Vertex d, const property_type* eplug)
42 : Base(s,d), m_eproperty(const_cast<property_type*>(eplug)) { }
44 property_type* get_property() { return m_eproperty; }
45 const property_type* get_property() const { return m_eproperty; }
48 property_type* m_eproperty;
51 template <class D, class V>
53 operator==(const detail::edge_desc_impl<D,V>& a,
54 const detail::edge_desc_impl<D,V>& b)
56 return a.get_property() == b.get_property();
58 template <class D, class V>
60 operator!=(const detail::edge_desc_impl<D,V>& a,
61 const detail::edge_desc_impl<D,V>& b)
63 return ! (a.get_property() == b.get_property());
66 // Order edges according to the address of their property object
67 template <class D, class V>
69 operator<(const detail::edge_desc_impl<D,V>& a,
70 const detail::edge_desc_impl<D,V>& b)
72 return a.get_property() < b.get_property();
74 template <class D, class V>
76 operator<=(const detail::edge_desc_impl<D,V>& a,
77 const detail::edge_desc_impl<D,V>& b)
79 return a.get_property() <= b.get_property();
81 template <class D, class V>
83 operator>(const detail::edge_desc_impl<D,V>& a,
84 const detail::edge_desc_impl<D,V>& b)
86 return a.get_property() > b.get_property();
88 template <class D, class V>
90 operator>=(const detail::edge_desc_impl<D,V>& a,
91 const detail::edge_desc_impl<D,V>& b)
93 return a.get_property() >= b.get_property();
101 template <class Char, class Traits, class D, class V>
102 std::basic_ostream<Char, Traits>&
103 operator<<(std::basic_ostream<Char, Traits>& os,
104 const boost::detail::edge_desc_impl<D,V>& e)
106 return os << "(" << e.m_source << "," << e.m_target << ")";
110 // Boost's functional/hash
112 template<typename D, typename V>
113 struct hash<boost::detail::edge_desc_impl<D, V> >
115 std::size_t operator()(const boost::detail::edge_desc_impl<D, V> & x) const
116 { return hash_value(x.get_property()); }
121 #endif // BOOST_GRAPH_DETAIL_DETAIL_EDGE_HPP