public void NotOverlappingPaths(string first, string second) { var firstPath = CreatePath(first); var secondPath = CreatePath(second); ((object)OverlapFinder.FindOverlap(firstPath, secondPath)) .Should().Be(Path.Empty); }
public void OverlappingPaths(string first, string second, string expected) { var firstPath = CreatePath(first); var secondPath = CreatePath(second); var expectedOverlap = CreatePath(expected); ((object)OverlapFinder.FindOverlap(firstPath, secondPath)) .Should().Be(expectedOverlap); }
public static Path Extend(this Path firstPath, Path secondPath, DirectedGraph graph) { ArgumentHelpers.ThrowIfNull(() => firstPath); ArgumentHelpers.ThrowIfNull(() => secondPath); ArgumentHelpers.ThrowIfNull(() => graph); var overlap = OverlapFinder.FindOverlap(firstPath, secondPath); if (!Path.IsEmpty(overlap)) { return(overlap); } var shortestPath = BreadthFirst.FindPath(graph, firstPath.End, node => node == secondPath.Start); if (Path.IsEmpty(shortestPath)) { return(Path.Empty); } return(Path.Join(firstPath, Path.Of(shortestPath.GetRange(1, shortestPath.Length - 2)), secondPath)); }