class CoverabilityGraph::Node
Attributes
graph[RW]
The graph this node belongs to
id[R]
unique ID
inputs[R]
Incoming edges
label[R]
Label of the node
markings[R]
Makking this node represents
name[R]
human readable name
omega_marked[R]
Omega-marked node (unlimited Petrinet -> coverabilitygraph)
outputs[R]
Outgoing edges
start[R]
True if this is the start-marking
Public Class Methods
new(options = {}) { |self| ... }
click to toggle source
# File lib/petri_net/coverability_graph/node.rb, line 23 def initialize(options = {}, &block) @id = next_object_id @name = (options[:name] or "Node#{@id}") @description = (options[:description] or "Node #{@id}") @inputs = Array.new @outputs = Array.new @label = (options[:label] or @name) @markings = options[:markings] @start = (options[:start] or false) if @markings.nil? raise ArgumentError.new "Every Node needs markings" end if @markings.include? Float::INFINITY @omega_marked = true else @omega_marked = false end yield self unless block.nil? end
Public Instance Methods
<=>(object)
click to toggle source
Compare-operator, other Operators are available through comparable-mixin
# File lib/petri_net/coverability_graph/node.rb, line 86 def <=>(object) return nil unless object.class.to_s == "PetriNet::CoverabilityGraph::Node" if @markings == object.markings return 0 end counter = 0 less = true self.markings.each do |marking| if marking <= object.markings[counter] && less less = true else less = false break end counter += 1 end if less return -1 end counter = 0 more = true self.markings.each do |marking| if marking >= object.markings[counter] && more more = true else more = false break end counter += 1 end if more return 1 end return nil end
add_omega(object)
click to toggle source
Add an omega-marking to a specified place
# File lib/petri_net/coverability_graph/node.rb, line 45 def add_omega object ret = Array.new if object.class.to_s == "PetriNet::CoverabilityGraph::Node" if self < object counter = 0 object.markings.each do |marking| if @markings[counter] < marking @markings[counter] = Float::INFINITY ret << counter end counter += 1 end else return false end elsif object.class.to_s == "Array" object.each do |place| markings[place] = Float::INFINITY ret = object end elsif object.class.to_s == "Fixnum" markings[object] = Float::INFINITY ret = [object] end @omega_marked = true ret end
gv_id()
click to toggle source
# File lib/petri_net/coverability_graph/node.rb, line 77 def gv_id "N#{@id}" end
to_gv()
click to toggle source
# File lib/petri_net/coverability_graph/node.rb, line 81 def to_gv "\t#{self.gv_id} [ label = \"#{@markings}\" ];\n" end
to_s()
click to toggle source
# File lib/petri_net/coverability_graph/node.rb, line 123 def to_s "#{@id}: #{@name} (#{@markings})" end
validate()
click to toggle source
# File lib/petri_net/coverability_graph/node.rb, line 73 def validate true end