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 20 def initialize(graph, options = {}, &block) @graph = graph @id = next_object_id @name = (options[:name] || "Edge#{@id}") @description = (options[:description] || "Edge #{@id}") @source = options[:source] @destination = options[:destination] @label = (options[:label] || @name) @probability = options[:probability] @transition = (options[:transition] || '') yield self unless block.nil? end
Public Instance Methods
==(object)
click to toggle source
# File lib/petri_net/graph/edge.rb, line 45 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 41 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 51 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 35 def validate return false unless @graph.nodes.key?(@source.name) && @graph.nodes.key?(@destination.name) true end
Private Instance Methods
probability_to_gv()
click to toggle source
# File lib/petri_net/graph/edge.rb, line 57 def probability_to_gv if @probability " [ label = \"#{@probability}\" ] " else '' end end