private bool IsPathCorrect(List <Edge <int> > path, UndirectedGraph <int, Edge <int> > g, int source, int target) { foreach (var edge in path) { if (!g.ContainsEdge(edge)) { throw new ArgumentException("Path is not part of the graph"); } } if (path.Count == 0 && source != target) { return(false); } int currentSource = source; foreach (var edge in path) { try { currentSource = EdmondsAlgorithm.GetTargetVertex(edge, currentSource); } catch (ArgumentException) { return(false); } } if (currentSource == target) { return(true); } else { return(false); } }
public void GetTargetVertex_ShouldReturn_0() { Assert.AreEqual(0, EdmondsAlgorithm.GetTargetVertex(new Edge <int>(0, 1), 1)); Assert.AreEqual(0, EdmondsAlgorithm.GetTargetVertex(new Edge <int>(1, 0), 1)); }