From 0869e044cbafdeea4ea39d3cced73cfffb1109bd Mon Sep 17 00:00:00 2001 From: Nick Klauer Date: Fri, 4 May 2012 07:49:10 -0500 Subject: [PATCH] use the path iterator properly --- .../lib/graph/path_evaluator.rb | 3 ++- .../spec/graph/path_evaluator_spec.rb | 22 +++++++++---------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/2-cheap-tourist-fast-tourist/lib/graph/path_evaluator.rb b/2-cheap-tourist-fast-tourist/lib/graph/path_evaluator.rb index 3b72dc3..4a239b0 100644 --- a/2-cheap-tourist-fast-tourist/lib/graph/path_evaluator.rb +++ b/2-cheap-tourist-fast-tourist/lib/graph/path_evaluator.rb @@ -28,7 +28,7 @@ def self.layover?(landing, takeoff) # Is the path too short (that is, is it only 2 links deep and # doesn't end at "Z" def self.path_too_short?(path) - path.length < 2 && path.end_node.name != "Z" + path.length < 2 && path.end_node[:name] != "Z" end # Does it touch the end node at all? @@ -39,6 +39,7 @@ def self.touches_end_node?(path) # Do the connecting flights overlap? That is, does # the landing flight land AFTER the takeoff of it's next connection? def self.connecting_flights_overlap?(path) + false # TODO: implement end end diff --git a/2-cheap-tourist-fast-tourist/spec/graph/path_evaluator_spec.rb b/2-cheap-tourist-fast-tourist/spec/graph/path_evaluator_spec.rb index e043083..e770360 100644 --- a/2-cheap-tourist-fast-tourist/spec/graph/path_evaluator_spec.rb +++ b/2-cheap-tourist-fast-tourist/spec/graph/path_evaluator_spec.rb @@ -1,4 +1,5 @@ +require 'pry' require_relative '../spec_helper' require_relative '../../lib/graph/db' require_relative '../../lib/graph/db_utils' @@ -7,7 +8,7 @@ require_relative '../../lib/file_parser' require_relative '../../lib/graph/path_evaluator' -describe "evaluating a path" do +describe "graph paths" do before do Neo4jDbUtils.new_temp_db @@ -23,18 +24,16 @@ Neo4jDbUtils.rm_db_storage end - it "should reject short paths that don't connect to the end airport" do - paths = @a.outgoing(:flies_to).eval_paths { |path| - puts path - return :include_and_continue - }.include_start_node - require 'pry' - binding.pry - fail "not implemented properly yet" - end + describe "evaluating a path" do - describe "path finding" do + it "should reject short paths that don't connect to the end airport" do + paths = @a.outgoing(:flies_to).depth(:all).unique(:node_path).eval_paths { |path| + PathEvaluator.evaluate_path(path) + } + binding.pry + fail "not implemented properly yet" + end it "should find paths from A to Z" do fail "not implemented" @@ -53,3 +52,4 @@ end end end +