Create a new edge
In:
vNodeOne : First node (can be a GraphViz::Node or a node ID)
vNodeTwo : Second node (can be a GraphViz::Node or a node ID)
parent_graph : Graph
# File lib/graphviz/edge.rb, line 30 def initialize( vNodeOne, vNodeTwo, parent_graph ) @node_one_id, @node_one_port = getNodeNameAndPort( vNodeOne ) @node_two_id, @node_two_port = getNodeNameAndPort( vNodeTwo ) @parent_graph = parent_graph @edge_attributes = GraphViz::Attrs::new( nil, "edge", EDGESATTRS ) @index = nil unless @parent_graph.directed? (@parent_graph.find_node(@node_one_id) || @parent_graph.add_nodes(@node_one_id)).incidents << (@parent_graph.find_node(@node_two_id) || @parent_graph.add_nodes(@node_two_id)) (@parent_graph.find_node(@node_two_id) || @parent_graph.add_nodes(@node_two_id)).neighbors << (@parent_graph.find_node(@node_one_id) || @parent_graph.add_nodes(@node_one_id)) end (@parent_graph.find_node(@node_one_id) || @parent_graph.add_nodes(@node_one_id)).neighbors << (@parent_graph.find_node(@node_two_id) || @parent_graph.add_nodes(@node_two_id)) (@parent_graph.find_node(@node_two_id) || @parent_graph.add_nodes(@node_two_id)).incidents << (@parent_graph.find_node(@node_one_id) || @parent_graph.add_nodes(@node_one_id)) end
Set values for edge attributes or get the value of the given edge attribute attribute_name
# File lib/graphviz/edge.rb, line 82 def []( attribute_name ) # Modification by axgle (http://github.com/axgle) if Hash === attribute_name attribute_name.each do |key, value| self[key] = value end else if @edge_attributes[attribute_name.to_s] @edge_attributes[attribute_name.to_s].clone else nil end end end
Set value attribute_value to the edge attribute attribute_name
# File lib/graphviz/edge.rb, line 75 def []=( attribute_name, attribute_value ) attribute_value = attribute_value.to_s if attribute_value.class == Symbol @edge_attributes[attribute_name.to_s] = attribute_value end
# File lib/graphviz/edge.rb, line 112 def each_attribut(global = true, &b) warn "`GraphViz::Edge#each_attribut` is deprecated, please use `GraphViz::Edge#each_attribute`" each_attribute(global, &b) end
Calls block once for each attribute of the edge, passing the name and value to the block as a two-element array.
If global is set to false, the block does not receive the attributes set globally
# File lib/graphviz/edge.rb, line 103 def each_attribute(global = true, &b) attrs = @edge_attributes.to_h if global attrs = pg.edge.to_h.merge attrs end attrs.each do |k,v| yield(k,v) end end
Return the index of the edge
# File lib/graphviz/edge.rb, line 67 def index @index end
Return the node one as string (so with port if any)
# File lib/graphviz/edge.rb, line 47 def node_one(with_port = true, escaped = true) if not(@node_one_port and with_port) escaped ? GraphViz.escape(@node_one_id) : @node_one_id else escaped ? GraphViz.escape(@node_one_id, :force => true) + ":#{@node_one_port}" : "#{@node_one_id}:#{@node_one_port}" end end
Return the node two as string (so with port if any)
# File lib/graphviz/edge.rb, line 57 def node_two(with_port = true, escaped = true) if not(@node_two_port and with_port) escaped ? GraphViz.escape(@node_two_id) : @node_two_id else escaped ? GraphViz.escape(@node_two_id, :force => true) + ":#{@node_two_port}" : "#{@node_two_id}:#{@node_two_port}" end end
Return the root graph
# File lib/graphviz/edge.rb, line 129 def root_graph return( (self.pg.nil?) ? nil : self.pg.root_graph ) end
Generated with the Darkfish Rdoc Generator 2.