private void GetLongestLink(IEdge edge) { int total = 0; var visitedEdges = new HashSet<IEdge>(); if (edge.ConnectsBothEndWithSameColorEdges()) { FullSearchLongestLink(); } else // only connects on one side, but do not know which side { total += edge.Adjacent.Vertices.Sum(vertex => GetLongestLink(edge, vertex, visitedEdges)); total -= 1; // the current edge is counted twice CompareLongestLink(total); } }