public IEnumerable <Vertex> ConnectPaths() { Reset(); // Avoid error if one of the collections is empty if (!_path.Any() || !_path2.Any()) { _connectedPath.AddRange(_path); _connectedPath.AddRange(_path2); return(_connectedPath); } // Combine _bestDist = LineSegment2.CalcLenght(_path.Last(), _path2.First()); _combineAction = Combine; // Combine2Reversed double dist = LineSegment2.CalcLenght(_path.Last(), _path2.Last()); if (dist < _bestDist) { _bestDist = dist; _combineAction = Combine2Reversed; } // Combine1Reversed dist = LineSegment2.CalcLenght(_path.First(), _path2.First()); if (dist < _bestDist) { _bestDist = dist; _combineAction = Combine1Reversed; } // CombineInvert dist = LineSegment2.CalcLenght(_path.First(), _path2.Last()); if (dist < _bestDist) { _bestDist = dist; _combineAction = CombineInvert; } _combineAction.Invoke(); return(_connectedPath); }