Tulip  5.4.0
Large graphs analysis and drawing
SimpleTest.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_SIMPLETEST_H
21 #define TULIP_SIMPLETEST_H
22 
23 #include <vector>
24 
25 #include <tulip/tulipconf.h>
26 
27 namespace tlp {
28 
29 class Graph;
30 struct edge;
31 
32 /**
33  * @ingroup Checks
34  * @brief Performs test to check if a graph is Simple.
35  * An undirected graph is simple if it has no loops and no more than one
36  * edge between any unordered pair of vertices.
37  * A directed graph is simple if has no loops and no more than one
38  * edge between any ordered pair of vertices.
39  **/
40 class TLP_SCOPE SimpleTest {
41 public:
42  /**
43  * @brief Checks if the graph is simple (i.e. it contains no self loops or parallel edges).
44  *
45  * @param graph The graph to check.
46  * @param directed Whether the graph shall be considered directed or not.
47  * @return bool True if the graph is simple, false otherwise.
48  **/
49  static bool isSimple(const Graph *graph, const bool directed = false);
50 
51  /**
52  * Makes the graph simple by removing self loops and parallel edges if any.
53  * The removed edges are stored in the removed vector.
54  */
55  /**
56  * @brief Makes the graph simple, by removing self loops and parallel edges if any.
57  *
58  * @param graph The graph to make simple.
59  * @param removed The edges that were removed to make the graph simple.
60  * @param directed Whether the graph shall be considered directed or not.
61  * @return void
62  **/
63  static void makeSimple(Graph *graph, std::vector<edge> &removed, const bool directed = false);
64 
65  /**
66  * Performs simple test and stores found parallel edges in the multipleEdges vector
67  * and found self loops in the loops vector.
68  * Returns true if the graph is simple, false otherwise.
69  */
70  /**
71  * @brief Checks if the graph is simple, and stores parallel edges and self loops in different
72  *vectors.
73  *
74  * @param graph The graph to check for simplicity.
75  * @param multipleEdges The parallel edges that need to be removed to make the graph simple.
76  *Defaults to 0.
77  * @param loops The self loops that need to be removed to make the graph simple. Defaults to 0.
78  * @param directed Whether the graph shall be considered directed or not.
79  * @return bool True if the graph is simple, false otherwise.
80  **/
81  static bool simpleTest(const Graph *graph, std::vector<edge> *multipleEdges = nullptr,
82  std::vector<edge> *loops = nullptr, const bool directed = false);
83 };
84 } // namespace tlp
85 #endif
Performs test to check if a graph is Simple. An undirected graph is simple if it has no loops and no ...
Definition: SimpleTest.h:40