Module: Dagnabit::Vertex::Neighbors

Defined in:
lib/dagnabit/vertex/neighbors.rb

Overview

Provides per-vertex connectivity queries.

This module should be included into a class that has been extended by Connectivity. See this module’s spec for example usage.

Instance Method Summary collapse

Instance Method Details

#ancestorsArray<ActiveRecord::Base>

Finds all ancestors of the receiver object.

Returns:

  • (Array<ActiveRecord::Base>)

    a list of ancestor vertices



22
23
24
# File 'lib/dagnabit/vertex/neighbors.rb', line 22

def ancestors
  self.class.ancestors_of(self)
end

#childrenArray<ActiveRecord::Base>

Finds all children of the receiver object.

Returns:

  • (Array<ActiveRecord::Base>)

    a list of child vertices



38
39
40
# File 'lib/dagnabit/vertex/neighbors.rb', line 38

def children
  self.class.children_of(self)
end

#descendantsArray<ActiveRecord::Base>

Finds all descendants of the receiver object.

Returns:

  • (Array<ActiveRecord::Base>)

    a list of descendant vertices



46
47
48
# File 'lib/dagnabit/vertex/neighbors.rb', line 46

def descendants
  self.class.descendants_of(self)
end

#parentsArray<ActiveRecord::Base>

Finds all parents of the receiver object.

Returns:

  • (Array<ActiveRecord::Base>)

    a list of parent vertices



30
31
32
# File 'lib/dagnabit/vertex/neighbors.rb', line 30

def parents
  self.class.parents_of(self)
end

#rootsArray<ActiveRecord::Base>

Finds all source vertices of the receiver object.

Returns:

  • (Array<ActiveRecord::Base>)

    a list of source vertices



14
15
16
# File 'lib/dagnabit/vertex/neighbors.rb', line 14

def roots
  self.class.roots_of(self)
end