// All intersections take 10 minutes - we'll notice if one isn't counted.
double turnDurationSecs = 10.0 * 60.0;
options.traversalCostModel = (new DummyCostModel(turnDurationSecs));
options.turnReluctance = (1.0);
State s0 = new State(options);
State s1 = e1.traverse(s0);
State s2 = e2.traverse(s1);
State s3 = e3.traverse(s2);
Edge partialE2First = intermediate.getIncoming().iterator().next();
Edge partialE2Second = intermediate.getOutgoing().iterator().next();
System.out.println(intermediate.getIncoming());
System.out.println(intermediate.getOutgoing());
State partialS0 = new State(options);
State partialS1 = e1.traverse(partialS0);
State partialS2A = partialE2First.traverse(partialS1);
State partialS2B = partialE2Second.traverse(partialS2A);
State partialS3 = e3.traverse(partialS2B);
// Should start at the same time.
assertEquals(s0.getTimeSeconds(), partialS0.getTimeSeconds());
// Time and cost should be the same up to a rounding difference.
assertTrue(Math.abs(s3.getTimeSeconds() - partialS3.getTimeSeconds()) <= 1);
assertTrue(Math.abs(s3.getElapsedTimeSeconds() - partialS3.getElapsedTimeSeconds()) <= 1);
assertTrue(Math.abs(s3.getWeight() - partialS3.getWeight()) <= 1);
// All intersections take 0 seconds now.
options.traversalCostModel = (new DummyCostModel(0.0));
State s0NoCost = new State(options);
State s1NoCost = e1.traverse(s0NoCost);
State s2NoCost = e2.traverse(s1NoCost);
State s3NoCost = e3.traverse(s2NoCost);
State partialS0NoCost = new State(options);
State partialS1NoCost = e1.traverse(partialS0NoCost);
State partialS2ANoCost = partialE2First.traverse(partialS1NoCost);
State partialS2BNoCost = partialE2Second.traverse(partialS2ANoCost);
State partialS3NoCost = e3.traverse(partialS2BNoCost);
// Time and cost should be the same up to a rounding difference.
assertTrue(Math.abs(s3NoCost.getTimeSeconds() - partialS3NoCost.getTimeSeconds()) <= 1);
assertTrue(Math.abs(s3NoCost.getElapsedTimeSeconds() - partialS3NoCost.getElapsedTimeSeconds()) <= 1);
assertTrue(Math.abs(s3NoCost.getWeight() - partialS3NoCost.getWeight()) <= 1);
// Difference in duration and weight between now and before should be
// entirely due to the crossing of 2 intersections at v2 and v3.
double expectedDifference = 2 * 10 * 60.0;
double durationDiff = s3.getTimeSeconds() - s3NoCost.getTimeSeconds();
double partialDurationDiff = partialS3.getTimeSeconds() - partialS3NoCost.getTimeSeconds();
assertTrue(Math.abs(durationDiff - expectedDifference) <= 1);
assertTrue(Math.abs(partialDurationDiff - expectedDifference) <= 1);
// Turn reluctance is 1.0, so weight == duration.
double weightDiff = s3.getWeight() - s3NoCost.getWeight();
double partialWeightDiff = partialS3.getWeight() - partialS3NoCost.getWeight();
assertTrue(Math.abs(weightDiff - expectedDifference) <= 1);
assertTrue(Math.abs(partialWeightDiff - expectedDifference) <= 1);
}