Sha256: bee04bfed8f663c83941f81228857c17d12e7cd5e50c3240fc20dad51b143cf2
Contents?: true
Size: 1.61 KB
Versions: 3
Compression:
Stored size: 1.61 KB
Contents
module Yargi # A set of vertices class VertexSet < ElementSet ### Factory section ####################################################### # Creates a VertexSet instance using _elements_ varargs. def self.[](*elements) VertexSet.new(elements) end ### Walking section ####################################################### # Returns incoming edges of all vertices of this set def in_edges(filter=nil, &block) r = self.collect {|v| v.in_edges(filter, &block) } EdgeSet.new(r).flatten.uniq end # Returns all back-adjacent vertices reachable from this set def in_adjacent(filter=nil, &block) r = self.collect {|v| v.in_adjacent(filter, &block) } VertexSet.new(r).flatten.uniq end # Returns all outgoing edges of all vertices of this set def out_edges(filter=nil, &block) r = self.collect {|v| v.out_edges(filter, &block) } EdgeSet.new(r).flatten.uniq end # Returns all forward-adjacent vertices reachable from this set def out_adjacent(filter=nil, &block) r = self.collect {|v| v.out_adjacent(filter, &block) } VertexSet.new(r).flatten.uniq end # Returns all adjacent vertices reachable from this set def adjacent(filter=nil, &block) (in_adjacent(filter, &block)+out_adjacent(filter, &block)).uniq end ### Protected section ##################################################### protected # Extends with VertexSet instead of ElementSet def extend_result(result) VertexSet.new(result) end end # module VertexSet end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
yargi-0.1.2 | lib/yargi/vertex_set.rb |
yargi-0.1.0 | lib/yargi/vertex_set.rb |
yargi-0.1.1 | lib/yargi/vertex_set.rb |