Class: Ogr::ConnectedComponents
- Inherits:
-
Object
- Object
- Ogr::ConnectedComponents
- Defined in:
- lib/ogr/connected_components.rb
Overview
ConnectedComponents class finds graph components
Instance Method Summary collapse
- #component(v) ⇒ Object
- #components ⇒ Object
- #connected?(v, u) ⇒ Boolean
- #count ⇒ Object
-
#initialize(graph) ⇒ ConnectedComponents
constructor
A new instance of ConnectedComponents.
Constructor Details
#initialize(graph) ⇒ ConnectedComponents
Returns a new instance of ConnectedComponents.
7 8 9 10 11 12 |
# File 'lib/ogr/connected_components.rb', line 7 def initialize(graph) @graph = graph @visited = {} @counter = 0 find_components end |
Instance Method Details
#component(v) ⇒ Object
18 19 20 |
# File 'lib/ogr/connected_components.rb', line 18 def component(v) visited[v] end |
#components ⇒ Object
22 23 24 |
# File 'lib/ogr/connected_components.rb', line 22 def components visited end |
#connected?(v, u) ⇒ Boolean
14 15 16 |
# File 'lib/ogr/connected_components.rb', line 14 def connected?(v, u) visited[v] == visited[u] end |
#count ⇒ Object
26 27 28 |
# File 'lib/ogr/connected_components.rb', line 26 def count counter end |