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