GEOS  3.13.0dev
ConnectedSubgraphFinder.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2001-2002 Vivid Solutions Inc.
7  * Copyright (C) 2005-2006 Refractions Research Inc.
8  *
9  * This is free software; you can redistribute and/or modify it under
10  * the terms of the GNU Lesser General Public Licence as published
11  * by the Free Software Foundation.
12  * See the COPYING file for more information.
13  *
14  **********************************************************************/
15 
16 #pragma once
17 
18 #include <geos/export.h>
19 #include <geos/planargraph/PlanarGraph.h> // for inlines
20 
21 #include <stack>
22 #include <vector>
23 
24 // Forward declarations
25 namespace geos {
26 namespace planargraph {
27 class PlanarGraph;
28 class Subgraph;
29 class Node;
30 }
31 }
32 
33 namespace geos {
34 namespace planargraph { // geos::planargraph
35 namespace algorithm { // geos::planargraph::algorithm
36 
42 class GEOS_DLL ConnectedSubgraphFinder {
43 public:
44 
46  :
47  graph(newGraph)
48  {}
49 
58  void getConnectedSubgraphs(std::vector<Subgraph*>& dest);
59 
60 private:
61 
62  PlanarGraph& graph;
63 
65  Subgraph* findSubgraph(Node* node);
66 
67 
74  void addReachable(Node* node, Subgraph* subgraph);
75 
81  void addEdges(Node* node, std::stack<Node*>& nodeStack,
82  Subgraph* subgraph);
83 
84  // Declare type as noncopyable
85  ConnectedSubgraphFinder(const ConnectedSubgraphFinder& other) = delete;
86  ConnectedSubgraphFinder& operator=(const ConnectedSubgraphFinder& rhs) = delete;
87 };
88 
89 } // namespace geos::planargraph::algorithm
90 } // namespace geos::planargraph
91 } // namespace geos
92 
A node in a PlanarGraph is a location where 0 or more Edge meet.
Definition: planargraph/Node.h:44
Represents a directed graph which is embeddable in a planar surface.
Definition: planargraph/PlanarGraph.h:59
A subgraph of a PlanarGraph.
Definition: Subgraph.h:52
Finds all connected Subgraphs of a PlanarGraph.
Definition: ConnectedSubgraphFinder.h:42
void getConnectedSubgraphs(std::vector< Subgraph * > &dest)
Store newly allocated connected Subgraphs into the given std::vector.
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25