Sha256: 5a4d5c3b274a8bce4aa79e2902275ff05856732d8b9bac593883a373508d3209

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

module Jumoku
  # A {RawDirectedTree} relax the undirected constraint of trees as defined in
  # Graph Theory. They remain connected and acyclic though.
  #
  # It thus uses `Plexus::DirectedGraphBuilder` as its backend.
  #
  # It offers limited functionalities, therefore the main tree structure you'll likely to
  # use is its extended version, {Arborescence}.
  #
  module RawDirectedTreeBuilder
    include Plexus::DirectedGraphBuilder
    include Shared

    # This method is called by the specialized implementations upon tree creation.
    #
    # Initialization parameters can include:
    #
    # * an array of branches to add
    # * one or several trees to copy (will be merged if multiple)
    #
    # @param *params [Hash] the initialization parameters
    # @return enhanced Plexus::DirectedGraph
    #
    def initialize(*params)
      super(*params) # Delegates to Plexus.
      @_options = (params.pop if params.last.is_a? Hash) || {}
      _delay { alias has_branch? has_arc? }
    end

    # Checks whether the tree is *really* a valid tree, that is if the
    # following conditions are fulfilled:
    #
    # * directed
    # * acyclic
    # * connected
    #
    # @return [true, false]
    #
    def valid?
      super and directed?
    end

    private

    def _branch_type
      DirectedBranch
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jumoku-0.2.5 lib/jumoku/builders/raw_directed_tree.rb