]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/graph/example/simple_planarity_test.cpp
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / boost / libs / graph / example / simple_planarity_test.cpp
CommitLineData
7c673cae
FG
1//=======================================================================
2// Copyright 2007 Aaron Windsor
3//
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//=======================================================================
8#include <iostream>
9#include <boost/graph/adjacency_list.hpp>
10#include <boost/graph/boyer_myrvold_planar_test.hpp>
11
7c673cae
FG
12int main(int argc, char** argv)
13{
14
f67539c2
TL
15 // This program illustrates a simple use of boyer_myrvold_planar_embedding
16 // as a simple yes/no test for planarity.
17
18 using namespace boost;
7c673cae 19
f67539c2
TL
20 typedef adjacency_list< vecS, vecS, undirectedS,
21 property< vertex_index_t, int > >
22 graph;
7c673cae 23
f67539c2
TL
24 graph K_4(4);
25 add_edge(0, 1, K_4);
26 add_edge(0, 2, K_4);
27 add_edge(0, 3, K_4);
28 add_edge(1, 2, K_4);
29 add_edge(1, 3, K_4);
30 add_edge(2, 3, K_4);
7c673cae 31
f67539c2
TL
32 if (boyer_myrvold_planarity_test(K_4))
33 std::cout << "K_4 is planar." << std::endl;
34 else
35 std::cout << "ERROR! K_4 should have been recognized as planar!"
36 << std::endl;
7c673cae 37
f67539c2
TL
38 graph K_5(5);
39 add_edge(0, 1, K_5);
40 add_edge(0, 2, K_5);
41 add_edge(0, 3, K_5);
42 add_edge(0, 4, K_5);
43 add_edge(1, 2, K_5);
44 add_edge(1, 3, K_5);
45 add_edge(1, 4, K_5);
46 add_edge(2, 3, K_5);
47 add_edge(2, 4, K_5);
7c673cae 48
f67539c2
TL
49 // We've almost created a K_5 - it's missing one edge - so it should still
50 // be planar at this point.
7c673cae 51
f67539c2
TL
52 if (boyer_myrvold_planarity_test(K_5))
53 std::cout << "K_5 (minus an edge) is planar." << std::endl;
54 else
55 std::cout << "ERROR! K_5 with one edge missing should"
56 << " have been recognized as planar!" << std::endl;
7c673cae 57
f67539c2
TL
58 // Now add the final edge...
59 add_edge(3, 4, K_5);
7c673cae 60
f67539c2
TL
61 if (boyer_myrvold_planarity_test(K_5))
62 std::cout << "ERROR! K_5 was recognized as planar!" << std::endl;
63 else
64 std::cout << "K_5 is not planar." << std::endl;
7c673cae 65
f67539c2 66 return 0;
7c673cae 67}