Class: PetriNet::ReachabilityGraph::Edge

Inherits:
Base
  • Object
show all
Defined in:
lib/petri_net/reachability_graph/edge.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#logger

Instance Method Summary collapse

Methods inherited from Base

#next_object_id, #reset

Constructor Details

#initialize(options = {}) {|_self| ... } ⇒ Edge

Creates an edge for PetriNet::ReachabilityGraph

Yields:

  • (_self)

Yield Parameters:



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/petri_net/reachability_graph/edge.rb', line 12

def initialize(options = {}, &block)
    @id = next_object_id
    @name = (options[:name] or "Edge#{@id}")
    @description = (options[:description] or "Edge #{@id}")
    @source = options[:source] 
    @destination = options[:destination]
    @label = (options[:label] or @name)
    @probability = options[:probability]

    yield self unless block.nil?
end

Instance Attribute Details

#graphObject

Graph this edge belongs to



7
8
9
# File 'lib/petri_net/reachability_graph/edge.rb', line 7

def graph
  @graph
end

#idObject (readonly)

Unique ID



5
6
7
# File 'lib/petri_net/reachability_graph/edge.rb', line 5

def id
  @id
end

#nameObject (readonly)

Human readable name



3
4
5
# File 'lib/petri_net/reachability_graph/edge.rb', line 3

def name
  @name
end

#probabilityObject

Probability of the relating transition



9
10
11
# File 'lib/petri_net/reachability_graph/edge.rb', line 9

def probability
  @probability
end

Instance Method Details

#==(object) ⇒ Object



33
34
35
36
# File 'lib/petri_net/reachability_graph/edge.rb', line 33

def ==(object)
    return false unless object.class.to_s == "PetriNet::ReachabilityGraph::Edge"
    (@source == object.yource && @destination == oject.destination)
end

#to_gvObject



29
30
31
# File 'lib/petri_net/reachability_graph/edge.rb', line 29

def to_gv
    "\t#{@source.gv_id} -> #{@destination.gv_id}#{probability_to_gv};\n"
end

#to_sObject



37
38
39
# File 'lib/petri_net/reachability_graph/edge.rb', line 37

def to_s
    "#{@id}: #{@name} #{@source.id} -> #{@destination} )"
end

#validateObject

Validates the data holded by this edge, this will be used while adding the edge to the graph



25
26
27
# File 'lib/petri_net/reachability_graph/edge.rb', line 25

def validate
    true
end