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/GraphCopy.h>
37 
38 namespace ogdf {
39 
50 private:
56  bool m_directed;
57  const Graph* m_graph;
58 
66  void prepareGraph(const Graph& graph);
67 
74  int computeConnectivity(node v, node u);
75 
84  int computeConnectivity(NodeArray<NodeArray<int>>& result);
85 
91  void duplicateEdges(Graph& graph);
92 
99  void restrictNodes(Graph& graph);
100 
108  node copyOf(node v, bool isSource = false) const;
109 
110 public:
117  explicit ConnectivityTester(bool nodeConnectivity = true, bool directed = false)
118  : ConnectivityTester(new MaxFlowGoldbergTarjan<int>(), nodeConnectivity, directed) {
119  m_usingDefaultMaxFlow = true;
120  }
121 
129  ConnectivityTester(MaxFlowModule<int>* flowAlgo, bool nodeConnectivity = true,
130  bool directed = false)
131  : m_flowAlgo(flowAlgo)
132  , m_source(nullptr)
133  , m_usingDefaultMaxFlow(false)
134  , m_graphCopied(false)
135  , m_nodeConnectivity(nodeConnectivity)
136  , m_directed(directed)
137  , m_graph(nullptr) { }
138 
143  if (m_usingDefaultMaxFlow) {
144  delete m_flowAlgo;
145  }
146 
147  if (m_graphCopied) {
148  delete m_graph;
149  }
150 
151  delete m_source;
152  }
153 
163  int computeConnectivity(const Graph& graph, node v, node u) {
164  prepareGraph(graph);
165 
166  return computeConnectivity(copyOf(v, true), copyOf(u));
167  }
168 
178  int computeConnectivity(const Graph& graph, NodeArray<NodeArray<int>>& result) {
179  prepareGraph(graph);
180 
181  return computeConnectivity(result);
182  }
183 };
184 
185 }
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
ogdf::ConnectivityTester::m_source
NodeArray< node > * m_source
Definition: ConnectivityTester.h:52
ogdf::ConnectivityTester::m_graph
const Graph * m_graph
Definition: ConnectivityTester.h:57
MaxFlowModule.h
Interface for Max Flow Algorithms.
ogdf::ConnectivityTester::m_graphCopied
bool m_graphCopied
Definition: ConnectivityTester.h:54
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:129
ogdf::ConnectivityTester::ConnectivityTester
ConnectivityTester(bool nodeConnectivity=true, bool directed=false)
Initializes a new connectivity tester using ogdf::MaxFlowGoldbergTarjan.
Definition: ConnectivityTester.h:117
ogdf::MaxFlowGoldbergTarjan
Computes a max flow via Preflow-Push (global relabeling and gap relabeling heuristic).
Definition: MaxFlowGoldbergTarjan.h:53
ogdf::ConnectivityTester::m_flowAlgo
MaxFlowModule< int > * m_flowAlgo
Definition: ConnectivityTester.h:51
ogdf::ConnectivityTester::~ConnectivityTester
~ConnectivityTester()
Destroys the connectivity tester and frees allocated memory.
Definition: ConnectivityTester.h:142
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:49
ogdf::ConnectivityTester::m_usingDefaultMaxFlow
bool m_usingDefaultMaxFlow
Definition: ConnectivityTester.h:53
GraphCopy.h
Declaration of graph copy classes.
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:651
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:862
ogdf::ConnectivityTester::m_nodeConnectivity
bool m_nodeConnectivity
Definition: ConnectivityTester.h:55
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:56
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:178
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:233
ogdf::ConnectivityTester::computeConnectivity
int computeConnectivity(const Graph &graph, node v, node u)
Computes the connectivity of two nodes.
Definition: ConnectivityTester.h:163