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 25 def initialize(options = {}, &block) @id = next_object_id @name = (options[:name] || "Node#{@id}") @description = (options[:description] || "Node #{@id}") @inputs = [] @outputs = [] @label = (options[:label] || @name) @markings = options[:markings] @start = (options[:start] || false) raise ArgumentError, 'Every Node needs markings' if @markings.nil? @omega_marked = if @markings.include? Float::INFINITY true else 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 87 def <=>(object) return nil unless object.class.to_s == 'PetriNet::CoverabilityGraph::Node' return 0 if @markings == object.markings counter = 0 less = true markings.each do |marking| if marking <= object.markings[counter] && less less = true else less = false break end counter += 1 end return -1 if less counter = 0 more = true markings.each do |marking| if marking >= object.markings[counter] && more more = true else more = false break end counter += 1 end return 1 if more 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 46 def add_omega(object) ret = [] 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 78 def gv_id "N#{@id}" end
to_gv()
click to toggle source
# File lib/petri_net/coverability_graph/node.rb, line 82 def to_gv "\t#{gv_id} [ label = \"#{@markings}\" ];\n" end
to_s()
click to toggle source
# File lib/petri_net/coverability_graph/node.rb, line 120 def to_s "#{@id}: #{@name} (#{@markings})" end
validate()
click to toggle source
# File lib/petri_net/coverability_graph/node.rb, line 74 def validate true end