Class: PetriNet::Graph::Edge
Direct Known Subclasses
Instance Attribute Summary collapse
-
#destination ⇒ Object
readonly
Destination of the edge.
-
#graph ⇒ Object
Graph this edge belongs to.
-
#id ⇒ Object
readonly
Unique ID.
-
#name ⇒ Object
readonly
Human readable name.
-
#probability ⇒ Object
Probability of the relating transition.
-
#source ⇒ Object
readonly
Source of the edge.
-
#transition ⇒ Object
readonly
Transition this edge is representing.
Attributes inherited from Base
Instance Method Summary collapse
- #==(object) ⇒ Object
-
#initialize(graph, options = {}) {|_self| ... } ⇒ Edge
constructor
Creates an edge for PetriNet::Graph.
- #to_gv ⇒ Object
- #to_s ⇒ Object
-
#validate ⇒ Object
Validates the data holded by this edge, this will be used while adding the edge to the graph.
Methods inherited from Base
Constructor Details
#initialize(graph, options = {}) {|_self| ... } ⇒ Edge
Creates an edge for PetriNet::Graph
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/petri_net/graph/edge.rb', line 18 def initialize(graph, = {}, &block) @graph = graph @id = next_object_id @name = ([:name] or "Edge#{@id}") @description = ([:description] or "Edge #{@id}") @source = [:source] @destination = [:destination] @label = ([:label] or @name) @probability = [:probability] @transition = ([:transition] or "") yield self unless block.nil? end |
Instance Attribute Details
#destination ⇒ Object (readonly)
Destination of the edge
13 14 15 |
# File 'lib/petri_net/graph/edge.rb', line 13 def destination @destination end |
#graph ⇒ Object
Graph this edge belongs to
7 8 9 |
# File 'lib/petri_net/graph/edge.rb', line 7 def graph @graph end |
#id ⇒ Object (readonly)
Unique ID
5 6 7 |
# File 'lib/petri_net/graph/edge.rb', line 5 def id @id end |
#name ⇒ Object (readonly)
Human readable name
3 4 5 |
# File 'lib/petri_net/graph/edge.rb', line 3 def name @name end |
#probability ⇒ Object
Probability of the relating transition
9 10 11 |
# File 'lib/petri_net/graph/edge.rb', line 9 def probability @probability end |
#source ⇒ Object (readonly)
Source of the edge
11 12 13 |
# File 'lib/petri_net/graph/edge.rb', line 11 def source @source end |
#transition ⇒ Object (readonly)
Transition this edge is representing
15 16 17 |
# File 'lib/petri_net/graph/edge.rb', line 15 def transition @transition end |
Instance Method Details
#==(object) ⇒ Object
41 42 43 44 |
# File 'lib/petri_net/graph/edge.rb', line 41 def ==(object) return false unless object.class.to_s == "PetriNet::ReachabilityGraph::Edge" (@source == object.yource && @destination == oject.destination) end |
#to_gv ⇒ Object
37 38 39 |
# File 'lib/petri_net/graph/edge.rb', line 37 def to_gv "\t#{@source.gv_id} -> #{@destination.gv_id}#{probability_to_gv};\n" end |
#to_s ⇒ Object
45 46 47 |
# File 'lib/petri_net/graph/edge.rb', line 45 def to_s "#{@id}: #{@name} #{@source.id} -> #{@destination} )" end |
#validate ⇒ Object
Validates the data holded by this edge, this will be used while adding the edge to the graph
33 34 35 |
# File 'lib/petri_net/graph/edge.rb', line 33 def validate true end |