Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

More efficient Graph#^ (+10%)

  • Loading branch information...
commit 1d169413811b371c57d5292efe56d2e57476cbe7 1 parent 2126fb2
@bfontaine authored
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/graph.rb
View
4 lib/graph.rb
@@ -225,8 +225,8 @@ def ^(other)
return nil
end
- nodes = (@nodes + other.nodes) - (@nodes & other.nodes)
- edges = (@edges + other.edges) - (@edges & other.edges)
+ nodes = (@nodes - other.nodes) + (other.nodes - @nodes)
+ edges = (@edges - other.edges) + (other.edges - @edges)
Graph.new(nodes, edges)
end
Please sign in to comment.
Something went wrong with that request. Please try again.