Tulip  5.0.0
Large graphs analysis and drawing
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
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 
20 #ifndef OUTERPLANARTEST_H
21 #define OUTERPLANARTEST_H
22 
23 #include <tulip/tuliphash.h>
24 #include <tulip/Observable.h>
25 #include <tulip/Graph.h>
26 
27 namespace tlp {
28 struct edge;
29 struct node;
30 
31 /**
32  * @ingroup Checks
33  * @brief Provides functions to test if a graph is Outer Planar.
34  *
35  * 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.
36  * 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."
37  **/
38 class TLP_SCOPE OuterPlanarTest : private Observable {
39 public:
40 
41  /**
42  * Returns true if the graph is outerplanar (i.e. a graph with an embedding
43  * in the plane such that all vertices belong to the unbounded face of the embedding),
44  * false otherwise.
45  */
46  /**
47  * @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).
48  *
49  * @param graph The graph to check.
50  * @return bool True if the graph is outer planar, false otherwise.
51  * @note this cannot be const as it uses the planarity test, which is not const and would be complex (impossible?) to make const.
52  **/
53  static bool isOuterPlanar(Graph *graph);
54 
55 private:
56  OuterPlanarTest() {}
57  // override Observable::treatEvent
58  void treatEvent(const Event&);
59 
60  bool compute(Graph *graph);
61 
62  /**
63  * @brief Singleton instance of this class.
64  **/
65  static OuterPlanarTest* instance;
66  /**
67  * @brief Stored results for graphs. When a graph is updated, its entry is removed from the hashmap.
68  **/
69  TLP_HASH_MAP<const Graph*, bool> resultsBuffer;
70 };
71 
72 }
73 
74 #endif
Provides functions to test if a graph is Outer Planar.
Event is the base class for all events used in the Observation mechanism.
Definition: Observable.h:47
The Observable class is the base of Tulip&#39;s observation system.
Definition: Observable.h:123