//public PointCaptureControl (List<Vector2> listVec) //{ // foreach (Vector2 v in listVec) // { // if (v.x > maxX) // maxX = (int) v.x; // if (v.y > maxY) // maxY = (int) v.y; // if (v.x<minX) // minX = (int) v.x; // if (v.y<minY) // minY = (int) v.y; // } //} public List <Point> DetectCapturePoints() { Graph Gr = new Graph(maxX / 10 + 1, maxY / 10 + 1, minX / 10, minY / 10); //DepthFirstPath dfs = new DepthFirstPath(StaticGameObject.pointPoligonColliderList, maxX / 10 + 1, maxY / 10 + 1); DepthFirstPath dfs = new DepthFirstPath(capturePointList, maxX / 10 + 1, maxY / 10 + 1); for (int x = minX / 10; x < maxX / 10 + 1; x++) { for (int y = minY / 10; y < maxY / 10 + 1; y++) { if (!dfs[x, y]) { dfs.FindAllVertics(Gr, x, y); if (Gr.crossing) { outOfCapture.AddRange(dfs.pointList); } else { inOfCapture.AddRange(dfs.pointList); } Gr.crossing = false; dfs.pointList = null; } } } return(inOfCapture); }
public static void test() { var graph = new Graph(6); graph.AddEdge(0, 1); graph.AddEdge(1, 2); graph.AddEdge(1, 4); graph.AddEdge(1, 3); graph.AddEdge(2, 3); graph.AddEdge(4, 3); graph.AddEdge(0, 5); graph.AddEdge(0, 4); var dfs = new DepthFirstPath(graph, 0); var s = new Stack <int>(); s.push(1); s.push(3); Console.WriteLine("Print paths:"); dfs.pathTo(3); dfs.pathTo(4); Debug.Assert(dfs.hasPath(4).Equals(true)); Debug.Assert(dfs.hasPath(3).Equals(true)); Debug.Assert(dfs.hasPath(5).Equals(true)); Debug.Assert(dfs.hasPath(2).Equals(true)); }