コード例 #1
0
        private static bool FindSeparatorOnTriangulation(PlanarNode src,
                                                         PlanarGraph pg,
                                                         SeparatorCycle sepCycle)
        {
            pg = Triangulation.GetTriangulation(pg);
            foreach (PlanarEdge f in Triangulation.triEdges)
            {
                if (((PlanarNode)f.neighboursAdjEdges[0]).nid == srcId ||
                    ((PlanarNode)f.neighboursAdjEdges[1]).nid == srcId)
                {
                    continue;
                }
                PlanarNode src2 = pg.planarNodes[srcId];
                Bfs.Src_all_bfs(src2, pg.planarNodes, pg.planarEdges, true);

                sepCycle.GetBoundaryCycle(pg, src2, f);

                int max = (int)(c * pg.planarNodes.Count);
                if (sepCycle.inC.Count < max &&
                    sepCycle.outC.Count < max)
                {
                    Console.WriteLine(gc + "  " + sepCycle.inC.Count);
                    //  ResetGraph(pg);
                    return(true);
                }

                ResetGraph(pg);
                //          break;
            }



            Console.WriteLine("not: " + gc + "  " + pg.planarNodes.Count);
            return(false);
        }
コード例 #2
0
        private static bool FindSeparator(PlanarNode src,
                                          List <PlanarNode> orderNodes, PlanarGraph pg,
                                          SeparatorCycle sepCycle, out PlanarEdge f)
        {
            List <PlanarNode> insideBoundaryNodes =
                orderNodes
                .Where(y => pg.planarNodes.ContainsKey(y.nid)).ToList();

            for (int i = 0; i < insideBoundaryNodes.Count - 1; i = i + 1)
            {
                for (int j = i + 1; j < insideBoundaryNodes.Count; j = j + 1)
                {
                    PlanarNode src2 = pg.planarNodes[srcId];
                    Bfs.Src_all_bfs(src2, pg.planarNodes, pg.planarEdges, true);
                    PlanarNode u = pg.planarNodes[insideBoundaryNodes[i].nid];
                    PlanarNode v = pg.planarNodes[insideBoundaryNodes[j].nid];
                    f      = new PlanarEdge(u, v);
                    f.eid  = -pg.planarEdges.Count - 1;
                    f.trgl = true;
                    pg.planarEdges.Add(f.eid, f);
                    u.edgesIds.Add(f.eid);
                    v.edgesIds.Add(f.eid);
                    //   SeparatorCycle sepCycle = new SeparatorCycle();
                    sepCycle.GetBoundaryCycle(pg, src2, f);

                    int max = (int)(c * pg.planarNodes.Count);
                    if (sepCycle.inC.Count < max &&
                        sepCycle.outC.Count < max)
                    {
                        Console.WriteLine(gc + "  " + sepCycle.inC.Count + " " + u.nid + " " + v.nid);
                        //  ResetGraph(pg);
                        return(true);
                    }

                    else
                    {
                        u.edgesIds.Remove(f.eid);
                        v.edgesIds.Remove(f.eid);
                    }
                    ResetGraph(pg);
                    //          break;
                }
            }
            f = null;
            if (c == 4f / 5)
            {
                c = 19f / 20;
                return(FindSeparator(src, orderNodes, pg, sepCycle, out f));
            }
            else

            {
                //   c = 4f / 5;
                Console.WriteLine("not: " + gc + "  " + pg.planarNodes.Count);
                return(FindSeparatorOnTriangulation(src, pg, sepCycle));
            }
        }