Module: Tangle::Mixin::Ancestry::Vertex
- Includes:
- Connectedness::Vertex
- Defined in:
- lib/tangle/mixin/ancestry.rb
Overview
Mixins for adding ancestry relations to vertices in a digraph
Instance Method Summary collapse
- #ancestor?(other) ⇒ Boolean
- #child?(other) ⇒ Boolean
- #child_edges ⇒ Object
- #children ⇒ Object
- #descendant?(other) ⇒ Boolean
- #parent?(other) ⇒ Boolean
- #parent_edges ⇒ Object
- #parents ⇒ Object
Methods included from Connectedness::Vertex
Instance Method Details
#ancestor?(other) ⇒ Boolean
42 43 44 |
# File 'lib/tangle/mixin/ancestry.rb', line 42 def ancestor?(other) connected?(other, test_method: :parent?) end |
#child?(other) ⇒ Boolean
54 55 56 |
# File 'lib/tangle/mixin/ancestry.rb', line 54 def child?(other) @graph.edges.any? { |edge| edge.parent?(self) && edge.child?(other) } end |
#child_edges ⇒ Object
46 47 48 |
# File 'lib/tangle/mixin/ancestry.rb', line 46 def child_edges @graph.edges { |edge| edge.parent?(self) } end |
#children ⇒ Object
50 51 52 |
# File 'lib/tangle/mixin/ancestry.rb', line 50 def children neighbours(child_edges) end |
#descendant?(other) ⇒ Boolean
58 59 60 |
# File 'lib/tangle/mixin/ancestry.rb', line 58 def descendant?(other) connected?(other, test_method: :child?) end |
#parent?(other) ⇒ Boolean
38 39 40 |
# File 'lib/tangle/mixin/ancestry.rb', line 38 def parent?(other) @graph.edges.any? { |edge| edge.child?(self) && edge.parent?(other) } end |
#parent_edges ⇒ Object
30 31 32 |
# File 'lib/tangle/mixin/ancestry.rb', line 30 def parent_edges @graph.edges { |edge| edge.child?(self) } end |
#parents ⇒ Object
34 35 36 |
# File 'lib/tangle/mixin/ancestry.rb', line 34 def parents neighbours(parent_edges) end |