]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/graph/test/is_straight_line_draw_test.cpp
1 //=======================================================================
2 // Copyright 2008 Aaron Windsor
4 // Distributed under the Boost Software License, Version 1.0. (See
5 // accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7 //=======================================================================
9 #include <boost/property_map/property_map.hpp>
10 #include <boost/core/lightweight_test.hpp>
11 #include <boost/graph/adjacency_list.hpp>
12 #include <boost/graph/properties.hpp>
13 #include <boost/graph/graph_traits.hpp>
14 #include <boost/graph/is_straight_line_drawing.hpp>
18 using namespace boost
;
26 int main(int, char*[])
28 typedef adjacency_list
< vecS
, vecS
, undirectedS
,
29 property
< vertex_index_t
, int > >
32 typedef std::vector
< coord_t
> drawing_storage_t
;
34 typedef boost::iterator_property_map
< drawing_storage_t::iterator
,
35 property_map
< graph_t
, vertex_index_t
>::type
>
42 drawing_storage_t
drawing_storage(num_vertices(g
));
43 drawing_t
drawing(drawing_storage
.begin(), get(vertex_index
, g
));
45 // two perpendicular lines that intersect at (1,1)
55 BOOST_TEST(!is_straight_line_drawing(g
, drawing
));
57 // two parallel horizontal lines
63 BOOST_TEST(is_straight_line_drawing(g
, drawing
));
65 // two parallel vertical lines
75 BOOST_TEST(is_straight_line_drawing(g
, drawing
));
77 // two lines that intersect at (1,1)
87 BOOST_TEST(!is_straight_line_drawing(g
, drawing
));
89 // K_4 arranged in a diamond pattern, so that edges intersect
98 drawing_storage
= drawing_storage_t(num_vertices(g
));
99 drawing
= drawing_t(drawing_storage
.begin(), get(vertex_index
, g
));
110 BOOST_TEST(!is_straight_line_drawing(g
, drawing
));
112 // K_4 arranged so that no edges intersect
122 BOOST_TEST(is_straight_line_drawing(g
, drawing
));
124 // a slightly more complicated example - edges (0,1) and (4,5)
132 drawing_storage
= drawing_storage_t(num_vertices(g
));
133 drawing
= drawing_t(drawing_storage
.begin(), get(vertex_index
, g
));
152 BOOST_TEST(!is_straight_line_drawing(g
, drawing
));
154 // form a graph consisting of a bunch of parallel vertical edges,
155 // then place an edge at various positions to intersect edges
157 for (int i
= 0; i
< 11; ++i
)
158 add_edge(2 * i
, 2 * i
+ 1, g
);
160 drawing_storage
= drawing_storage_t(num_vertices(g
));
161 drawing
= drawing_t(drawing_storage
.begin(), get(vertex_index
, g
));
163 for (int i
= 0; i
< 10; ++i
)
165 drawing
[2 * i
].x
= i
;
166 drawing
[2 * i
].y
= 0;
167 drawing
[2 * i
+ 1].x
= i
;
168 drawing
[2 * i
+ 1].y
= 10;
171 // put the final edge as a horizontal edge intersecting one other edge
177 BOOST_TEST(!is_straight_line_drawing(g
, drawing
));
179 // make the final edge a diagonal intersecting multiple edges
185 BOOST_TEST(!is_straight_line_drawing(g
, drawing
));
193 BOOST_TEST(!is_straight_line_drawing(g
, drawing
));
195 return boost::report_errors();