private Directions JoinTwoCycles(Directions firstCycle, Directions secondCycle, EdgePair edges) { var firstRoute = firstCycle.GetRoute(edges.FirstCycleEdge); var secondRoute = secondCycle.GetRoute(edges.SecondCycleEdge); var closest = graph.PickClosestPoint(firstRoute.From, edges.SecondCycleEdge.Vertices); firstCycle.AddRoute(firstRoute.From, closest); var otherEndOfSecondRoute = secondRoute.From.Equals(secondRoute.To) ? secondRoute.To : secondRoute.Points.Single(p => !p.Equals(closest)); firstCycle.AddRoute(otherEndOfSecondRoute, firstRoute.To); firstCycle.Merge(secondCycle); firstCycle.RemoveRoute(firstRoute); firstCycle.RemoveRoute(secondRoute); return firstCycle; }
protected override void Given() { directions = new Directions(); directions.AddRoute(PointMother.USAPoints.UniversityAve, PointMother.USAPoints.LocustSt); directions.AddRoute(PointMother.USAPoints.LocustSt, PointMother.USAPoints.ShawSt); directions.AddRoute(PointMother.USAPoints.RaccoonSt, PointMother.USAPoints.UniversityAve); directions.AddRoute(PointMother.USAPoints.AshworthRd, PointMother.USAPoints.ShawSt); directions.AddRoute(PointMother.USAPoints.RaccoonSt, PointMother.USAPoints.AshworthRd); }