lib/jumoku/builders/arborescence.rb
# Return the list of a node's neighbours, that is, offsprings of node's
# parent siblings (cousins).
#
# @param [Node] node
# @param [Hash] options
# @option options [true, false] :siblings whether to include the node's
#   siblings in the list
# @return [Array<Node>]
#
Return the list of a node's neighbours, that is, offsprings of node's
parent siblings (cousins).
Return the list of a node ' s neighbours that is offsprings of node ' s parent siblings ( cousins ) .
def neighbours(node, options = {:siblings => false})
      return [] if root?(node)
      if root?(parent(node))
        nghb = offsprings(parent(node))
        nghb.delete_if { |child| child == node } unless options[:siblings]
        return nghb.map { |child| [child] }
      end
      nghb = siblings(parent(node)).map do |sibling|
        offsprings(sibling)
      end
      nghb << siblings(node) if options[:siblings]
      nghb
    end
def neighbours ( node , options = { :siblings => false } ) return [ ] if root? ( node ) if root? ( parent ( node ) ) nghb = offsprings ( parent ( node ) ) nghb . delete_if { | child | child == node } unless options [ :siblings ] return nghb . map { | child | [ child ] } end nghb = siblings ( parent ( node ) ) . map do | sibling | offsprings ( sibling ) end nghb << siblings ( node ) if options [ :siblings ] nghb end
Return the list of a node's neighbours, that is, offsprings of node's
parent siblings (cousins).
Return the list of a node ' s neighbours that is offsprings of node ' s parent siblings ( cousins ) .
# special case when the node is the root # special case when the node is a root's child # general case
None
Array<Node>
node
<not_specific>
options
:siblings whether to include the node's siblings in the list
: siblings whether to include the node ' s siblings in the list
<not_specific>
None