Class: Mementus::Pipes::IncomingEdges
- Inherits:
-
Object
- Object
- Mementus::Pipes::IncomingEdges
- Defined in:
- lib/mementus/pipes/incoming_edges.rb
Instance Method Summary collapse
Instance Method Details
#process(graph, source) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/mementus/pipes/incoming_edges.rb', line 4 def process(graph, source) ids = source.respond_to?(:id) ? [source.id] : source.map(&:id) incoming = [] graph.each_node do |graph_node| graph.each_adjacent(graph_node.id) do |adj_node| incoming << Mementus::Edge.new(from: graph_node, to: adj_node) if ids.include?(adj_node.id) end end incoming end |