profile.hpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. //
  2. //=======================================================================
  3. // Copyright 2002 Marc Wintermantel ([email protected])
  4. // ETH Zurich, Center of Structure Technologies
  5. // (https://web.archive.org/web/20050307090307/http://www.structures.ethz.ch/)
  6. //
  7. // Distributed under the Boost Software License, Version 1.0. (See
  8. // accompanying file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. //=======================================================================
  11. #ifndef BOOST_GRAPH_PROFILE_HPP
  12. #define BOOST_GRAPH_PROFILE_HPP
  13. #include <boost/graph/graph_traits.hpp>
  14. #include <boost/detail/numeric_traits.hpp>
  15. #include <boost/graph/bandwidth.hpp>
  16. namespace boost
  17. {
  18. template < typename Graph, typename VertexIndexMap >
  19. typename graph_traits< Graph >::vertices_size_type profile(
  20. const Graph& g, VertexIndexMap index)
  21. {
  22. typename graph_traits< Graph >::vertices_size_type b = 0;
  23. typename graph_traits< Graph >::vertex_iterator i, end;
  24. for (boost::tie(i, end) = vertices(g); i != end; ++i)
  25. {
  26. b += ith_bandwidth(*i, g, index) + 1;
  27. }
  28. return b;
  29. }
  30. template < typename Graph >
  31. typename graph_traits< Graph >::vertices_size_type profile(const Graph& g)
  32. {
  33. return profile(g, get(vertex_index, g));
  34. }
  35. } // namespace boost
  36. #endif // BOOST_GRAPH_PROFILE_HPP