Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

ConnectivityTester.h
Go to the documentation of this file.
1 
32 #pragma once
33 
34 #include <ogdf/basic/Graph.h>
35 #include <ogdf/basic/basic.h>
38 
39 namespace ogdf {
40 
51 private:
57  bool m_directed;
58  const Graph* m_graph;
59 
67  void prepareGraph(const Graph& graph);
68 
75  int computeConnectivity(node v, node u);
76 
85  int computeConnectivity(NodeArray<NodeArray<int>>& result);
86 
92  void duplicateEdges(Graph& graph);
93 
100  void restrictNodes(Graph& graph);
101 
109  node copyOf(node v, bool isSource = false) const;
110 
111 public:
118  explicit ConnectivityTester(bool nodeConnectivity = true, bool directed = false)
119  : ConnectivityTester(new MaxFlowGoldbergTarjan<int>(), nodeConnectivity, directed) {
120  m_usingDefaultMaxFlow = true;
121  }
122 
130  ConnectivityTester(MaxFlowModule<int>* flowAlgo, bool nodeConnectivity = true,
131  bool directed = false)
132  : m_flowAlgo(flowAlgo)
133  , m_source(nullptr)
134  , m_usingDefaultMaxFlow(false)
135  , m_graphCopied(false)
136  , m_nodeConnectivity(nodeConnectivity)
137  , m_directed(directed)
138  , m_graph(nullptr) { }
139 
144  if (m_usingDefaultMaxFlow) {
145  delete m_flowAlgo;
146  }
147 
148  if (m_graphCopied) {
149  delete m_graph;
150  }
151 
152  delete m_source;
153  }
154 
164  int computeConnectivity(const Graph& graph, node v, node u) {
165  prepareGraph(graph);
166 
167  return computeConnectivity(copyOf(v, true), copyOf(u));
168  }
169 
179  int computeConnectivity(const Graph& graph, NodeArray<NodeArray<int>>& result) {
180  prepareGraph(graph);
181 
182  return computeConnectivity(result);
183  }
184 };
185 
186 }
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
ogdf::ConnectivityTester::m_source
NodeArray< node > * m_source
Definition: ConnectivityTester.h:53
ogdf::ConnectivityTester::m_graph
const Graph * m_graph
Definition: ConnectivityTester.h:58
Graph.h
Includes declaration of graph class.
MaxFlowModule.h
Interface for Max Flow Algorithms.
ogdf::ConnectivityTester::m_graphCopied
bool m_graphCopied
Definition: ConnectivityTester.h:55
ogdf::ConnectivityTester::ConnectivityTester
ConnectivityTester(MaxFlowModule< int > *flowAlgo, bool nodeConnectivity=true, bool directed=false)
Initializes a new onnectivity tester using a custom ogdf::MaxFlowModule.
Definition: ConnectivityTester.h:130
ogdf::ConnectivityTester::ConnectivityTester
ConnectivityTester(bool nodeConnectivity=true, bool directed=false)
Initializes a new connectivity tester using ogdf::MaxFlowGoldbergTarjan.
Definition: ConnectivityTester.h:118
ogdf::MaxFlowGoldbergTarjan
Computes a max flow via Preflow-Push (global relabeling and gap relabeling heuristic).
Definition: MaxFlowGoldbergTarjan.h:60
ogdf::ConnectivityTester::m_flowAlgo
MaxFlowModule< int > * m_flowAlgo
Definition: ConnectivityTester.h:52
ogdf::ConnectivityTester::~ConnectivityTester
~ConnectivityTester()
Destroys the connectivity tester and frees allocated memory.
Definition: ConnectivityTester.h:143
MaxFlowGoldbergTarjan.h
Declaration and implementation of Goldberg-Tarjan max-flow algorithm with global relabeling and gap r...
ogdf::ConnectivityTester
Naive implementation for testing the connectivity of a graph.
Definition: ConnectivityTester.h:50
ogdf::ConnectivityTester::m_usingDefaultMaxFlow
bool m_usingDefaultMaxFlow
Definition: ConnectivityTester.h:54
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:658
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:869
ogdf::ConnectivityTester::m_nodeConnectivity
bool m_nodeConnectivity
Definition: ConnectivityTester.h:56
basic.h
Basic declarations, included by all source files.
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
ogdf::ConnectivityTester::m_directed
bool m_directed
Definition: ConnectivityTester.h:57
ogdf::MaxFlowModule< int >
ogdf::ConnectivityTester::computeConnectivity
int computeConnectivity(const Graph &graph, NodeArray< NodeArray< int >> &result)
Computes the connectivity of all nodes of the provided graph.
Definition: ConnectivityTester.h:179
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:240
ogdf::ConnectivityTester::computeConnectivity
int computeConnectivity(const Graph &graph, node v, node u)
Computes the connectivity of two nodes.
Definition: ConnectivityTester.h:164