public void RecursiveSeparation(PlanarGraph graph, PlanarNode src, int lev0) { List <long> c = new List <long>(); PlanarSeparator sep = new PlanarSeparator(); sep.Separate(ref graph, out c); Console.WriteLine(graph.planarNodes.Count); Console.ReadKey(); GetFirstCycle(graph, src, lev0); List <PlanarNode> cycleNodes = cycle.Select(x => graph.planarNodes[x]).ToList(); PlanarGraph g0 = new PlanarGraph(inC, cycleNodes, src, new Dictionary <int, PlanarEdge> (graph.planarEdges)); // PlanarGraph g1 = new PlanarGraph(outC, cycleNodes, src, graph.planarEdges); RecursiveSeparation(g0, g0.planarNodes.ElementAt(0).Value, 10000); // RecursiveSeparation(g1, g1.planarNodes.ElementAt(0).Value, 10000); }
public static void GetDecomposition(PlanarGraph g, PlanarNode src) { PlanarSeparator sep = new PlanarSeparator(); List <long> cycle; // Bfs.Src_all_bfs(g.planarNodes.First().Value, g.planarEdges, true); SeparatorCycle c = new SeparatorCycle(); c.GetCycle_U_V(g, g.planarNodes[3682132103], g.planarNodes[34073500]); cycle = c.cycle; Dictionary <long, PlanarNode> nodes = new Dictionary <long, PlanarNode>(g.planarNodes); List <long> nullKeys = new List <long>(); foreach (KeyValuePair <long, PlanarNode> pair in nodes) { PlanarNode n = pair.Value; if (n == null || n.edgesIds.Count == 0) { nullKeys.Add(pair.Key); continue; } n.state = 0; n.dist = 0; } foreach (long nid in nullKeys) { nodes.Remove(nid); } foreach (long nid in cycle) { nodes.Remove(nid); } Dictionary <long, List <long> > components = new Dictionary <long, List <long> >(); foreach (PlanarNode x in nodes.Values) { if (x.state > 0) { continue; } // Bfs.Src_all_bfs(x, g.planarEdges, false); List <long> comp = Bfs.part0; components.Add(x.nid, comp); } int max = 0; long maxKey = 0; foreach (KeyValuePair <long, List <long> > pair in components) { if (nodes.ContainsKey(pair.Key) && pair.Value.Count > max) { max = pair.Value.Count; maxKey = pair.Key; } } PlanarNode s0 = nodes.Last().Value; }