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.



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

def head
  @head
end

#tailObject (readonly)

Returns the value of attribute tail.



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

def tail
  @tail
end

Instance Method Details

#each_vertex(&block) ⇒ Object



21
22
23
# File 'lib/tangle/directed/edge.rb', line 21

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

#head?(vertex) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/tangle/directed/edge.rb', line 13

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

#tail?(vertex) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/tangle/directed/edge.rb', line 17

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

#to_sObject Also known as: inspect



25
26
27
# File 'lib/tangle/directed/edge.rb', line 25

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