Tulip  5.2.0
Large graphs analysis and drawing
OuterPlanarTest.h
1 /*
2  *
3  * This file is part of Tulip (http://tulip.labri.fr)
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
36  *in such a way that all of the vertices belong to the unbounded face of the drawing.
37  * Alternatively, a graph G is outerplanar if the graph formed from G by adding a new vertex, with
38  *edges connecting it to all the other vertices, is a planar graph."
39  **/
40 class TLP_SCOPE OuterPlanarTest : private Observable {
41 public:
42  /**
43  * Returns true if the graph is outerplanar (i.e. a graph with an embedding
44  * in the plane such that all vertices belong to the unbounded face of the embedding),
45  * false otherwise.
46  */
47  /**
48  * @brief Checks if a graph is outer planar (i.e. a graph with an embedding in the plane such that
49  *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
54  *complex (impossible?) to make const.
55  **/
56  static bool isOuterPlanar(Graph *graph);
57 
58 private:
59  OuterPlanarTest() {}
60  // override Observable::treatEvent
61  void treatEvent(const Event &) override;
62 
63  bool compute(Graph *graph);
64 
65  /**
66  * @brief Singleton instance of this class.
67  **/
68  static OuterPlanarTest *instance;
69  /**
70  * @brief Stored results for graphs. When a graph is updated, its entry is removed from the
71  *hashmap.
72  **/
73  TLP_HASH_MAP<const Graph *, bool> resultsBuffer;
74 };
75 }
76 
77 #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:51
The Observable class is the base of Tulip&#39;s observation system.
Definition: Observable.h:141