Class: Tangle::Directed::Edge

Inherits:
Edge
  • Object
show all
Defined in:
lib/tangle/directed/edge.rb

Overview

An edge in a directed graph

Instance Attribute Summary collapse

Attributes inherited from Edge

#name

Attributes included from Mixin::Initialize

#mixins

Instance Method Summary collapse

Methods inherited from Edge

#[], #include?, #initialize, #loop?, #walk

Constructor Details

This class inherits a constructor from Tangle::Edge

Instance Attribute Details

#headObject (readonly)

Returns the value of attribute head.



9
10
11
# File 'lib/tangle/directed/edge.rb', line 9

def head
  @head
end

#tailObject (readonly)

Returns the value of attribute tail.



9
10
11
# File 'lib/tangle/directed/edge.rb', line 9

def tail
  @tail
end

Instance Method Details

#each_vertex(&block) ⇒ Object



19
20
21
# File 'lib/tangle/directed/edge.rb', line 19

def each_vertex(&block)
  [@tail, @head].each(&block)
end

#head?(vertex) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/tangle/directed/edge.rb', line 11

def head?(vertex)
  @head == vertex
end

#tail?(vertex) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/tangle/directed/edge.rb', line 15

def tail?(vertex)
  @tail == vertex
end

#to_sObject Also known as: inspect



23
24
25
# File 'lib/tangle/directed/edge.rb', line 23

def to_s
  "{#{@tail}-->#{@head}}"
end