Tulip  5.2.0
Large graphs analysis and drawing
BiconnectedTest.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 TULIP_BICONNEX_H
21 #define TULIP_BICONNEX_H
22 
23 #include <tulip/MutableContainer.h>
24 #include <tulip/Observable.h>
25 #include <tulip/Graph.h>
26 
27 namespace tlp {
28 
29 /**
30  * @ingroup Checks
31  * @brief Performs a test of biconnexity on the graph, and provides a function to make a graph
32  *biconnected.
33  * From Wikipedia: "A biconnected graph is connected and nonseparable, meaning that if any vertex
34  *were to be removed, the graph will remain connected."
35  **/
36 class TLP_SCOPE BiconnectedTest : private Observable {
37 
38 public:
39  /**
40  * @brief Checks whether the graph is biconnected (i.e. removing one edge does not disconnect the
41  *graph, at least two must be removed).
42  *
43  * @param graph The graph to check for biconnectivity.
44  * @return bool True if the graph is biconnected, false otherwise.
45  **/
46  static bool isBiconnected(const Graph *graph);
47 
48  /**
49  * If the graph is not biconnected, adds edges in order to make the graph
50  * biconnected. The new edges are added in addedEdges.
51  */
52  /**
53  * @brief Adds edges to make the graph biconnected.
54  *
55  * @param graph The graph to make biconnected.
56  * @param addedEdges The edges that were added in the process.
57  * @return void
58  **/
59  static void makeBiconnected(Graph *graph, std::vector<edge> &addedEdges);
60 
61 private:
63 
64  /**
65  * @brief Makes the graph biconnected.
66  *
67  * @param graph The graph to make biconnected.
68  * @param addedEdges The edges that were added to make it biconnected.
69  * @return void
70  **/
71  void connect(Graph *graph, std::vector<edge> &addedEdges);
72 
73  /**
74  * @brief check if the graph is biconnected.
75  *
76  * @param graph the graph to check.
77  * @return bool true if the graph is biconnected, false otherwise.
78  **/
79  bool compute(const Graph *graph);
80 
81  // override of Observable::treatEvent to remove the cached result for a graph if it is modified.
82  void treatEvent(const Event &) override;
83 
84  /**
85  * @brief Singleton instance of this class.
86  **/
87  static BiconnectedTest *instance;
88  /**
89  * @brief Stored results for graphs. When a graph is updated, its entry is removed from the
90  *hashmap.
91  **/
92  TLP_HASH_MAP<const Graph *, bool> resultsBuffer;
93 };
94 }
95 
96 #endif
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
Performs a test of biconnexity on the graph, and provides a function to make a graph biconnected...