Sha256: 4cf309f9ea565d9e5d177261e6a589ee7e46cf948561ed2f607f1e2139098cf6

Contents?: true

Size: 1000 Bytes

Versions: 2

Compression:

Stored size: 1000 Bytes

Contents

module Yargi
  
  # A set of edges
  class EdgeSet < ElementSet
    
    ### Factory section #######################################################
    
    # Creates a VertexSet instance using _elements_ varargs.
    def self.[](*elements)
      EdgeSet.new(elements)
    end
    
    ### Walking section #######################################################
    
    # Returns a VertexSet with reachable vertices using the edges of this set.
    def target
      VertexSet.new(self.collect {|e| e.target}).uniq
    end
    alias :targets :target
    
    # Returns a VertexSet with back-reachable vertices using the edges of this 
    # set.
    def source
      VertexSet.new(self.collect {|e| e.source}).uniq
    end
    alias :sources :source
    
    ### Protected section #####################################################
    protected
        
    # Extends with EdgeSet instead of ElementSet
    def extend_result(result)
      EdgeSet.new(result)
    end

  end # module EdgeSet

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
yargi-0.1.0 lib/yargi/edge_set.rb
yargi-0.1.1 lib/yargi/edge_set.rb