Class: GraphFilter
- Inherits:
-
Object
- Object
- GraphFilter
- Defined in:
- lib/graph_filter.rb
Instance Method Summary collapse
- #filter(source, destination) ⇒ Object
-
#initialize(graph) ⇒ GraphFilter
constructor
A new instance of GraphFilter.
Constructor Details
#initialize(graph) ⇒ GraphFilter
Returns a new instance of GraphFilter.
5 6 7 |
# File 'lib/graph_filter.rb', line 5 def initialize(graph) @graph = graph end |
Instance Method Details
#filter(source, destination) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/graph_filter.rb', line 9 def filter(source, destination) return @graph if source.nil? && destination.nil? if !source.nil? && destination.nil? return reduce(@graph, source) end if !destination.nil? && source.nil? return reduce(@graph.reverse, destination).reverse end search(@graph, source, destination) end |