1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/stdcpp/tsrc/Boost_test/graph/src/dijkstra_cc.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,126 @@
1.4 +//=======================================================================
1.5 +// Copyright 2002 Indiana University.
1.6 +// Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek
1.7 +//
1.8 +// Distributed under the Boost Software License, Version 1.0. (See
1.9 +// accompanying file LICENSE_1_0.txt or copy at
1.10 +// http://www.boost.org/LICENSE_1_0.txt)
1.11 +//=======================================================================
1.12 +/*
1.13 + * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved.
1.14 +*/
1.15 +
1.16 +#include <boost/config.hpp>
1.17 +#include <boost/concept_archetype.hpp>
1.18 +#include <boost/graph/dijkstra_shortest_paths.hpp>
1.19 +#include <boost/graph/graph_archetypes.hpp>
1.20 +#ifdef __SYMBIAN32__
1.21 +#include "std_log_result.h"
1.22 +#define LOG_FILENAME_LINE __FILE__, __LINE__
1.23 +#endif
1.24 +typedef boost::default_constructible_archetype<
1.25 + boost::sgi_assignable_archetype<> > dist_value;
1.26 +
1.27 +// So generate_infinity works...
1.28 +namespace std {
1.29 + template <>
1.30 + class numeric_limits<dist_value> {
1.31 + public:
1.32 + static dist_value max BOOST_PREVENT_MACRO_SUBSTITUTION () {
1.33 + return boost::static_object<dist_value>::get();
1.34 + }
1.35 + };
1.36 +}
1.37 +
1.38 +dist_value abs(const dist_value& x) { return x; }
1.39 +std::size_t abs(std::size_t x) { return x; }
1.40 +
1.41 +int main()
1.42 +{
1.43 + using namespace boost;
1.44 + typedef default_constructible_archetype<
1.45 + sgi_assignable_archetype<
1.46 + equality_comparable_archetype<> > > vertex_t;
1.47 + {
1.48 + typedef incidence_graph_archetype<vertex_t, directed_tag,
1.49 + allow_parallel_edge_tag> IncidenceGraph;
1.50 + typedef vertex_list_graph_archetype<vertex_t, directed_tag,
1.51 + allow_parallel_edge_tag, IncidenceGraph> graph_t;
1.52 + graph_t& g = static_object<graph_t>::get();
1.53 + vertex_t s;
1.54 + typedef graph_traits<graph_t>::edge_descriptor edge_t;
1.55 + readable_property_map_archetype<edge_t, std::size_t> weight;
1.56 + readable_property_map_archetype<vertex_t, int> index;
1.57 + read_write_property_map_archetype<vertex_t, std::size_t> distance;
1.58 + dijkstra_shortest_paths(g, s,
1.59 + vertex_index_map(index).
1.60 + weight_map(weight).
1.61 + distance_map(distance));
1.62 + }
1.63 + {
1.64 + typedef incidence_graph_archetype<vertex_t, directed_tag,
1.65 + allow_parallel_edge_tag> IncidenceGraph;
1.66 + typedef vertex_list_graph_archetype<vertex_t, directed_tag,
1.67 + allow_parallel_edge_tag, IncidenceGraph> Graph;
1.68 + vertex_t s;
1.69 + typedef graph_traits<Graph>::edge_descriptor edge_t;
1.70 + readable_property_map_archetype<edge_t, std::size_t> weight;
1.71 + typedef property_graph_archetype<Graph, vertex_index_t, std::size_t>
1.72 + graph_t;
1.73 + graph_t& g = static_object<graph_t>::get();
1.74 + read_write_property_map_archetype<vertex_t, vertex_t> pred;
1.75 + dijkstra_shortest_paths(g, s,
1.76 + predecessor_map(pred).
1.77 + weight_map(weight));
1.78 + }
1.79 + {
1.80 + typedef incidence_graph_archetype<vertex_t, directed_tag,
1.81 + allow_parallel_edge_tag> IncidenceGraph;
1.82 + typedef vertex_list_graph_archetype<vertex_t, directed_tag,
1.83 + allow_parallel_edge_tag, IncidenceGraph> Graph;
1.84 + vertex_t s;
1.85 + typedef property_graph_archetype<Graph, edge_weight_t, std::size_t>
1.86 + graph_t;
1.87 + graph_t& g = static_object<graph_t>::get();
1.88 + read_write_property_map_archetype<vertex_t, vertex_t> pred;
1.89 + readable_property_map_archetype<vertex_t, int> index;
1.90 + dijkstra_shortest_paths(g, s,
1.91 + predecessor_map(pred).
1.92 + vertex_index_map(index));
1.93 + }
1.94 + {
1.95 + typedef incidence_graph_archetype<vertex_t, directed_tag,
1.96 + allow_parallel_edge_tag> IncidenceGraph;
1.97 + typedef vertex_list_graph_archetype<vertex_t, directed_tag,
1.98 + allow_parallel_edge_tag, IncidenceGraph> graph_t;
1.99 + graph_t& g = static_object<graph_t>::get();
1.100 + vertex_t s;
1.101 + typedef graph_traits<graph_t>::edge_descriptor edge_t;
1.102 + readable_property_map_archetype<edge_t, dist_value> weight;
1.103 + readable_property_map_archetype<vertex_t, int> index;
1.104 + read_write_property_map_archetype<vertex_t, color_value_archetype> color;
1.105 + read_write_property_map_archetype<vertex_t, dist_value> distance;
1.106 + typedef binary_function_archetype<dist_value, dist_value, dist_value>
1.107 + Combine;
1.108 + Combine combine = static_object<Combine>::get();
1.109 + typedef binary_predicate_archetype<dist_value, dist_value>
1.110 + Compare;
1.111 + Compare compare = static_object<Compare>::get();
1.112 + dijkstra_visitor<> vis;
1.113 +
1.114 + dijkstra_shortest_paths(g, s, color_map(color).
1.115 + vertex_index_map(index).
1.116 + weight_map(weight).
1.117 + distance_map(distance).
1.118 + distance_combine(combine).
1.119 + distance_compare(compare).
1.120 + visitor(vis));
1.121 + }
1.122 + #ifdef __SYMBIAN32__
1.123 + std_log(LOG_FILENAME_LINE,"[End Test Case ]");
1.124 +
1.125 + testResultXml("dijkstra_cc");
1.126 + close_log_file();
1.127 +#endif
1.128 + return 0;
1.129 +}