lib/rgl/dot.rb in rgl-0.5.1 vs lib/rgl/dot.rb in rgl-0.5.2
- old
+ new
@@ -15,10 +15,14 @@
# Returns a label for vertex v. Default is v.to_s
def vertex_label(v)
v.to_s
end
+ def vertex_id(v)
+ v
+ end
+
# Return a RGL::DOT::Digraph for directed graphs or a DOT::Graph for an
# undirected Graph. _params_ can contain any graph property specified in
# rdot.rb.
#
def to_dot_graph(params = {})
@@ -27,19 +31,19 @@
graph = (directed? ? DOT::Digraph : DOT::Graph).new(params)
edge_class = directed? ? DOT::DirectedEdge : DOT::Edge
each_vertex do |v|
graph << DOT::Node.new(
- 'name' => v.object_id,
+ 'name' => vertex_id(v),
'fontsize' => fontsize,
'label' => vertex_label(v)
)
end
each_edge do |u, v|
graph << edge_class.new(
- 'from' => u.object_id,
- 'to' => v.object_id,
+ 'from' => vertex_id(u),
+ 'to' => vertex_id(v),
'fontsize' => fontsize
)
end
graph