|
1 //======================================================================= |
|
2 // Copyright 2002 Indiana University. |
|
3 // Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek |
|
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 * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved. |
|
11 */ |
|
12 |
|
13 #include <boost/config.hpp> |
|
14 #include <boost/concept_archetype.hpp> |
|
15 #include <boost/graph/dijkstra_shortest_paths.hpp> |
|
16 #include <boost/graph/graph_archetypes.hpp> |
|
17 #ifdef __SYMBIAN32__ |
|
18 #include "std_log_result.h" |
|
19 #define LOG_FILENAME_LINE __FILE__, __LINE__ |
|
20 #endif |
|
21 typedef boost::default_constructible_archetype< |
|
22 boost::sgi_assignable_archetype<> > dist_value; |
|
23 |
|
24 // So generate_infinity works... |
|
25 namespace std { |
|
26 template <> |
|
27 class numeric_limits<dist_value> { |
|
28 public: |
|
29 static dist_value max BOOST_PREVENT_MACRO_SUBSTITUTION () { |
|
30 return boost::static_object<dist_value>::get(); |
|
31 } |
|
32 }; |
|
33 } |
|
34 |
|
35 dist_value abs(const dist_value& x) { return x; } |
|
36 std::size_t abs(std::size_t x) { return x; } |
|
37 |
|
38 int main() |
|
39 { |
|
40 using namespace boost; |
|
41 typedef default_constructible_archetype< |
|
42 sgi_assignable_archetype< |
|
43 equality_comparable_archetype<> > > vertex_t; |
|
44 { |
|
45 typedef incidence_graph_archetype<vertex_t, directed_tag, |
|
46 allow_parallel_edge_tag> IncidenceGraph; |
|
47 typedef vertex_list_graph_archetype<vertex_t, directed_tag, |
|
48 allow_parallel_edge_tag, IncidenceGraph> graph_t; |
|
49 graph_t& g = static_object<graph_t>::get(); |
|
50 vertex_t s; |
|
51 typedef graph_traits<graph_t>::edge_descriptor edge_t; |
|
52 readable_property_map_archetype<edge_t, std::size_t> weight; |
|
53 readable_property_map_archetype<vertex_t, int> index; |
|
54 read_write_property_map_archetype<vertex_t, std::size_t> distance; |
|
55 dijkstra_shortest_paths(g, s, |
|
56 vertex_index_map(index). |
|
57 weight_map(weight). |
|
58 distance_map(distance)); |
|
59 } |
|
60 { |
|
61 typedef incidence_graph_archetype<vertex_t, directed_tag, |
|
62 allow_parallel_edge_tag> IncidenceGraph; |
|
63 typedef vertex_list_graph_archetype<vertex_t, directed_tag, |
|
64 allow_parallel_edge_tag, IncidenceGraph> Graph; |
|
65 vertex_t s; |
|
66 typedef graph_traits<Graph>::edge_descriptor edge_t; |
|
67 readable_property_map_archetype<edge_t, std::size_t> weight; |
|
68 typedef property_graph_archetype<Graph, vertex_index_t, std::size_t> |
|
69 graph_t; |
|
70 graph_t& g = static_object<graph_t>::get(); |
|
71 read_write_property_map_archetype<vertex_t, vertex_t> pred; |
|
72 dijkstra_shortest_paths(g, s, |
|
73 predecessor_map(pred). |
|
74 weight_map(weight)); |
|
75 } |
|
76 { |
|
77 typedef incidence_graph_archetype<vertex_t, directed_tag, |
|
78 allow_parallel_edge_tag> IncidenceGraph; |
|
79 typedef vertex_list_graph_archetype<vertex_t, directed_tag, |
|
80 allow_parallel_edge_tag, IncidenceGraph> Graph; |
|
81 vertex_t s; |
|
82 typedef property_graph_archetype<Graph, edge_weight_t, std::size_t> |
|
83 graph_t; |
|
84 graph_t& g = static_object<graph_t>::get(); |
|
85 read_write_property_map_archetype<vertex_t, vertex_t> pred; |
|
86 readable_property_map_archetype<vertex_t, int> index; |
|
87 dijkstra_shortest_paths(g, s, |
|
88 predecessor_map(pred). |
|
89 vertex_index_map(index)); |
|
90 } |
|
91 { |
|
92 typedef incidence_graph_archetype<vertex_t, directed_tag, |
|
93 allow_parallel_edge_tag> IncidenceGraph; |
|
94 typedef vertex_list_graph_archetype<vertex_t, directed_tag, |
|
95 allow_parallel_edge_tag, IncidenceGraph> graph_t; |
|
96 graph_t& g = static_object<graph_t>::get(); |
|
97 vertex_t s; |
|
98 typedef graph_traits<graph_t>::edge_descriptor edge_t; |
|
99 readable_property_map_archetype<edge_t, dist_value> weight; |
|
100 readable_property_map_archetype<vertex_t, int> index; |
|
101 read_write_property_map_archetype<vertex_t, color_value_archetype> color; |
|
102 read_write_property_map_archetype<vertex_t, dist_value> distance; |
|
103 typedef binary_function_archetype<dist_value, dist_value, dist_value> |
|
104 Combine; |
|
105 Combine combine = static_object<Combine>::get(); |
|
106 typedef binary_predicate_archetype<dist_value, dist_value> |
|
107 Compare; |
|
108 Compare compare = static_object<Compare>::get(); |
|
109 dijkstra_visitor<> vis; |
|
110 |
|
111 dijkstra_shortest_paths(g, s, color_map(color). |
|
112 vertex_index_map(index). |
|
113 weight_map(weight). |
|
114 distance_map(distance). |
|
115 distance_combine(combine). |
|
116 distance_compare(compare). |
|
117 visitor(vis)); |
|
118 } |
|
119 #ifdef __SYMBIAN32__ |
|
120 std_log(LOG_FILENAME_LINE,"[End Test Case ]"); |
|
121 |
|
122 testResultXml("dijkstra_cc"); |
|
123 close_log_file(); |
|
124 #endif |
|
125 return 0; |
|
126 } |