Class: Mementus::DepthFirstSearch

Inherits:
Object
  • Object
show all
Defined in:
lib/mementus/depth_first_search.rb

Instance Method Summary collapse

Constructor Details

#initialize(graph, start_id, method = :out) ⇒ DepthFirstSearch

Returns a new instance of DepthFirstSearch.



3
4
5
6
7
8
# File 'lib/mementus/depth_first_search.rb', line 3

def initialize(graph, start_id, method=:out)
  @graph = graph
  @start_id = start_id
  @method = method
  @visited = { @start_id => true }
end

Instance Method Details

#each(&block) ⇒ Object



10
11
12
# File 'lib/mementus/depth_first_search.rb', line 10

def each(&block)
  visit(@graph.node(@start_id), &block)
end