class PetriNet::Graph::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(graph, options = {}) { |self| ... }
click to toggle source
# File lib/petri_net/graph/node.rb, line 23 def initialize(graph, options = {}, &block) @graph = graph @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/graph/node.rb, line 106 def <=>(object) return nil unless object.class.to_s == "PetriNet::ReachabilityGraph::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/graph/node.rb, line 50 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] elsif object.class.to_s == "PetriNet::ReachabilityGraph::Node" raise PetriNet::Graph::InfinityError("ReachabilityGraphs do not support omega-markings") end @omega_marked = true ret end
gv_id()
click to toggle source
# File lib/petri_net/graph/node.rb, line 97 def gv_id "N#{@id}" end
include_place(place)
click to toggle source
# File lib/petri_net/graph/node.rb, line 80 def include_place(place) places = @graph.net.get_place_list included_places = Array.new i = 0 @markings.each do |m| if m > 0 included_places << places[i] end i += 1 end included_places.include? place end
infinite?()
click to toggle source
# File lib/petri_net/graph/node.rb, line 45 def infinite? @omega_marked end
to_gv()
click to toggle source
# File lib/petri_net/graph/node.rb, line 101 def to_gv "\t#{self.gv_id} [ label = \"#{@markings}\" ];\n" end
to_s()
click to toggle source
# File lib/petri_net/graph/node.rb, line 143 def to_s "#{@id}: #{@name} (#{@markings})" end
validate()
click to toggle source
# File lib/petri_net/graph/node.rb, line 93 def validate true end