![]() |
Tulip
4.6.0
Better Visualization Through Research
|
00001 /* 00002 * 00003 * This file is part of Tulip (www.tulip-software.org) 00004 * 00005 * Authors: David Auber and the Tulip development Team 00006 * from LaBRI, University of Bordeaux 00007 * 00008 * Tulip is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License 00010 * as published by the Free Software Foundation, either version 3 00011 * of the License, or (at your option) any later version. 00012 * 00013 * Tulip is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00016 * See the GNU General Public License for more details. 00017 * 00018 */ 00019 ///@cond DOXYGEN_HIDDEN 00020 00021 00022 #ifndef TULIP_SIMPLETEST_H 00023 #define TULIP_SIMPLETEST_H 00024 00025 #include <tulip/tuliphash.h> 00026 #include <tulip/Observable.h> 00027 #include <tulip/Graph.h> 00028 00029 namespace tlp { 00030 00031 /** 00032 * @ingroup Checks 00033 * @brief Performs test to check if a graph is Simple. 00034 * From Wikipedia: "A simple graph is an undirected graph that has no loops and no more than one edge between any two different vertices." 00035 **/ 00036 class TLP_SCOPE SimpleTest : private Observable { 00037 public: 00038 00039 /** 00040 * @brief Checks if the graph is simple (i.e. it contains no self loops or parallel edges). 00041 * 00042 * @param graph The graph to check. 00043 * @return bool True if the graph is simple, false otherwise. 00044 **/ 00045 static bool isSimple(const Graph *graph); 00046 00047 /** 00048 * Makes the graph simple by removing self loops and parallel edges if any. 00049 * The removed edges are stored in the removed vector. 00050 */ 00051 /** 00052 * @brief Makes the graph simple, by removing self loops and parallel edges if any. 00053 * 00054 * @param graph The graph to make simple. 00055 * @param removed The edges that were removed to make the graph simple. 00056 * @return void 00057 **/ 00058 static void makeSimple(Graph* graph, std::vector<edge> &removed); 00059 00060 /** 00061 * Performs simple test and stores found parallel edges in the multipleEdges vector 00062 * and found self loops in the loops vector. 00063 * Returns true if the graph is simple, false otherwise. 00064 */ 00065 /** 00066 * @brief Checks if the graph is simple, and stores parallel edges and self loops in different vectors. 00067 * 00068 * @param graph The graph to check for simplicity. 00069 * @param multipleEdges The parallel edges that need to be removed to make the graph simple. Defaults to 0. 00070 * @param loops The self loops that need to be removed to make the graph simple. Defaults to 0. 00071 * @return bool True if the graph is simple, false otherwise. 00072 **/ 00073 static bool simpleTest(const Graph *graph, std::vector<edge> *multipleEdges=NULL, std::vector<edge> *loops=NULL); 00074 00075 private: 00076 SimpleTest(); 00077 // override Observable::treatEvent 00078 void treatEvent(const Event&); 00079 void deleteResult(Graph *graph); 00080 00081 /** 00082 * @brief Singleton instance of this class. 00083 **/ 00084 static SimpleTest *instance; 00085 /** 00086 * @brief Stored results for graphs. When a graph is updated, its entry is removed from the hashmap. 00087 **/ 00088 TLP_HASH_MAP<const Graph*, bool> resultsBuffer; 00089 }; 00090 00091 00092 } 00093 #endif 00094 ///@endcond