Class: GV::Edge

Inherits:
Component show all
Defined in:
lib/gv.rb

Overview

Represents a connection between nodes

Instance Attribute Summary

Attributes inherited from Component

#graph

Instance Method Summary collapse

Methods inherited from Component

#==, #[], #[]=, #hash, #html, #name

Constructor Details

#initialize(graph, name, tail, head) ⇒ Edge

Returns a new instance of Edge.



135
136
137
138
139
# File 'lib/gv.rb', line 135

def initialize(graph, name, tail, head)
  @graph = graph

  @ptr = Libcgraph.agedge(graph.ptr, tail.ptr, head.ptr, name, 1)
end

Instance Method Details

#headNode

Returns the head node of the edge.

Returns:

  • (Node)

    the head node of the edge



142
143
144
# File 'lib/gv.rb', line 142

def head
  Node.new @graph, Libcgraph.aghead(ptr)
end

#tailNode

Returns the tail node of the edge.

Returns:

  • (Node)

    the tail node of the edge



147
148
149
# File 'lib/gv.rb', line 147

def tail
  Node.new @graph, Libcgraph.agtail(ptr)
end