Sha256: 5c883f06bc9de8ab77a11c184c9551e4139a7c4e7db8552a996a2c17f19d2b69
Contents?: true
Size: 1.56 KB
Versions: 1
Compression:
Stored size: 1.56 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
yargi-0.2.0 | lib/yargi/vertex_set.rb |