class PetriNet::Graph::Edge

Attributes

destination[R]

Destination of the edge

graph[RW]

Graph this edge belongs to

id[R]

Unique ID

name[R]

Human readable name

probability[RW]

Probability of the relating transition

source[R]

Source of the edge

transition[R]

Transition this edge is representing

Public Class Methods

new(graph, options = {}) { |self| ... } click to toggle source

Creates an edge for PetriNet::Graph

# File lib/petri_net/graph/edge.rb, line 18
def initialize(graph, options = {}, &block)
    @graph = graph
    @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]
    @transition = (options[:transition] or "")

    yield self unless block.nil?
end

Public Instance Methods

==(object) click to toggle source
# File lib/petri_net/graph/edge.rb, line 42
def ==(object)
    return false unless object.class.to_s == "PetriNet::ReachabilityGraph::Edge"
    (@source == object.yource && @destination == oject.destination)
end
to_gv() click to toggle source
# File lib/petri_net/graph/edge.rb, line 38
def to_gv
    "\t#{@source.gv_id} -> #{@destination.gv_id}#{probability_to_gv};\n"
end
to_s() click to toggle source
# File lib/petri_net/graph/edge.rb, line 46
def to_s
    "#{@id}: #{@name} #{@source} -> #{@destination} )"
end
validate() click to toggle source

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

# File lib/petri_net/graph/edge.rb, line 33
def validate
    return false unless ( @graph.nodes.has_key? @source.name and @graph.nodes.has_key? @destination.name )
    true
end

Private Instance Methods

probability_to_gv() click to toggle source
# File lib/petri_net/graph/edge.rb, line 51
def probability_to_gv
    if @probability 
        " [ label = \"#{@probability.to_s}\" ] "
    else
        ''
    end
end