You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#!/usr/bin/env rubyrequire'graphviz'require'graphviz/theory'graph=GraphViz.graph'escaping-sut'do |g|
g.add_nodes'alice@example.com'g.add_nodes'bob@example.com'g.add_edges'alice@example.com','bob@example.com'endtheory=GraphViz::Theory.newgraphroute=theory.moore_dijkstra'alice@example.com','bob@simplymeasured.com'puts"alice -> bob distance: #{route[:distance]}"
Expected result:
alice -> bob distance: 1
Actual result
~/.rbenv/versions/2.1.0-preview1/lib/ruby/gems/2.1.0/gems/ruby-graphviz-1.0.9/lib/graphviz/theory.rb:249:in `block in distance_matrix': undefined method `index' for nil:NilClass (NoMethodError)
from ~/.rbenv/versions/2.1.0-preview1/lib/ruby/gems/2.1.0/gems/ruby-graphviz-1.0.9/lib/graphviz.rb:233:in `block in each_edge'
from /Users/joseph/.rbenv/versions/2.1.0-preview1/lib/ruby/gems/2.1.0/gems/ruby-graphviz-1.0.9/lib/graphviz.rb:232:in `each'
from ~/.rbenv/versions/2.1.0-preview1/lib/ruby/gems/2.1.0/gems/ruby-graphviz-1.0.9/lib/graphviz.rb:232:in `each_edge'
from /Users/joseph/.rbenv/versions/2.1.0-preview1/lib/ruby/gems/2.1.0/gems/ruby-graphviz-1.0.9/lib/graphviz/theory.rb:248:in `distance_matrix'
from ~/.rbenv/versions/2.1.0-preview1/lib/ruby/gems/2.1.0/gems/ruby-graphviz-1.0.9/lib/graphviz/theory.rb:72:in `moore_dijkstra'
from graphs/minimal.rb:15:in `<main>'
Example script:
Expected result:
Actual result
Which ends up coming from this line: https://github.com/glejeune/Ruby-Graphviz/blob/v1.0.9/lib/graphviz/theory.rb#L249
Looking at the implementation of Edge#node_one, it is escaping the node id.
But looking at GraphViz#get_node, it's apparent that this function does not expect an escaped value.
A quick search implies that this method is only used in Edge#output, Theory#adjacency_matrix, Theory#incidence_matrix, Theory#degree, and Theory#distance_matrix.
I'd argue that none of the uses in Theory should have the escaping. I think it makes sense to push the escaping into Edge#output.
Does that sound good?
The text was updated successfully, but these errors were encountered: