Tulip  4.3.0
Better Visualization Through Research
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Groups Pages
OuterPlanarTest.h
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux 1 and Inria Bordeaux - Sud Ouest
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 ///@cond DOXYGEN_HIDDEN
20 
21 #ifndef OUTERPLANARTEST_H
22 #define OUTERPLANARTEST_H
23 
24 #include <tulip/tuliphash.h>
25 #include <tulip/Observable.h>
26 
27 namespace tlp {
28 
29 class Graph;
30 struct edge;
31 struct node;
32 
33 /**
34  * @ingroup Checks
35  * @brief Provides functions to test if a graph is Outer Planar.
36  *
37  * From Wikipedia: "An OuterPlanar Graph is a graph that can be drawn in the plane without crossings in such a way that all of the vertices belong to the unbounded face of the drawing.
38  * Alternatively, a graph G is outerplanar if the graph formed from G by adding a new vertex, with edges connecting it to all the other vertices, is a planar graph."
39  **/
40 class TLP_SCOPE OuterPlanarTest : private Observable {
41 public:
42 
43  /**
44  * Returns true if the graph is outerplanar (i.e. a graph with an embedding
45  * in the plane such that all vertices belong to the unbounded face of the embedding),
46  * false otherwise.
47  */
48  /**
49  * @brief Checks if a graph is outer planar (i.e. a graph with an embedding in the plane such that all vertices belong to the unbounded face of the embedding).
50  *
51  * @param graph The graph to check.
52  * @return bool True if the graph is outer planar, false otherwise.
53  * @note this cannot be const as it uses the planarity test, which is not const and would be complex (impossible?) to make const.
54  **/
55  static bool isOuterPlanar(Graph *graph);
56 
57 private:
58  OuterPlanarTest() {}
59  // override Observable::treatEvent
60  void treatEvent(const Event&);
61 
62  bool compute(Graph *graph);
63 
64  /**
65  * @brief Singleton instance of this class.
66  **/
67  static OuterPlanarTest* instance;
68  /**
69  * @brief Stored results for graphs. When a graph is updated, its entry is removed from the hashmap.
70  **/
71  TLP_HASH_MAP<unsigned long, bool> resultsBuffer;
72 };
73 
74 }
75 
76 #endif
77 ///@endcond