private void Walkup(Vertex <T> vertex, IEdge <Vertex <T> > edge) { var source = edge.Source; var target = edge.Target; if (source.Equals(target)) { selfLoopsNew.Add(edge); return; } var w = vertex.Equals(source) ? target : vertex; if (w.DFSNumber < vertex.DFSNumber || edge.Equals(w.DFSEdge)) { return; } w.BackEdges.Add(edge); var timestamp = vertex.DFSNumber; w.BackedgeFlag = timestamp; var leadVertex = w; while (true) { var foundRoot = true; // Move to the root of the current bicomp or the first visited // vertex on the bicomp by going up each side in parallel foreach (var faceVertex in IterateBothSides(leadVertex)) { if (faceVertex.Visited == timestamp) { foundRoot = false; break; } leadVertex = faceVertex; leadVertex.Visited = timestamp; } // If we've found the root of a bicomp through a path we haven't // seen before, update pertinent_roots with a handle to the // current bicomp. Otherwise, we've just seen a path we've been // up before, so break out of the main while loop. if (foundRoot) { var dfsChild = leadVertex.CanonicalDFSChild; var parent = dfsChild.Parent; dfsChild.DFSChildHandle.FirstVertex.Visited = timestamp; dfsChild.DFSChildHandle.SecondVertex.Visited = timestamp; if (dfsChild.LowPoint < vertex.DFSNumber || dfsChild.LeastAncestor < vertex.DFSNumber ) { parent.PertinentRoots.AddLast(dfsChild.DFSChildHandle); } else { parent.PertinentRoots.AddFirst(dfsChild.DFSChildHandle); } if (parent != vertex && parent.Visited != timestamp) { leadVertex = parent; } else { break; } } else { break; } } }
/// <summary> /// すでに辺が作成されているか調べます。 /// </summary> /// <param name="ed">調べたい辺</param> protected bool CheckEdgeExist(IEdge ed) { foreach (IEdge item in edge) if (ed.Equals(item)) return true; return false; }