public void Kruskal() { if (checkOriented()) { Debug.LogError("Graph is oriented : Kruskal wont work properly"); return; } List <int> whitePts = new List <int> (); List <int> grayPts = new List <int> (); List <Edge> unadded = new List <Edge>(); for (int i = 1; i <= Edge.edgeCount; i++) { unadded.Add(Edge.edges[i]); } Debug.Log(AlgoSearch.cycleSearch(unadded)); unadded.Sort(new EdgeCompByWeight()); List <Edge> added = new List <Edge>(); for (int i = 1; i <= Point.pointCount; i++) { whitePts.Add(i); } while (unadded.Count != 0) { Edge current = unadded[0]; added.Add(unadded[0]); unadded.RemoveAt(0); if (!AlgoSearch.cycleSearch(added)) { command.AddCommand(-current.number, Color.yellow); if (whitePts.Contains(current.start)) { whitePts.Remove(current.start); command.AddCommand(current.start, Color.cyan); grayPts.Add(current.start); } if (whitePts.Contains(current.end)) { whitePts.Remove(current.end); command.AddCommand(current.end, Color.cyan); grayPts.Add(current.end); } } else { command.AddCommand(-current.number, Color.gray); added.RemoveAt(added.Count - 1); } } StartCoroutine(command.support()); }
public void Redraw() { Color pointColor = material.color; for (int i = 1; i <= Point.pointCount; i++) { AlgoSearch.RecolorPoint(pointColor, i); Point.Points [i].DestroySupportLabel(); } Color edgeColor = edgeMaterial.color; for (int i = 1; i <= Edge.edgeCount; i++) { AlgoSearch.RecolorEdge(edgeColor, i); Edge.edges [i].DestroySupportLabel(); } }