Example #1
0
 private void removeBridges(Graph g2)
 {
     for (int i = 0; i < g2.Count; i++)
     {
         if (g2[i].Degree == 2)
         {
             //creapuente2nodos(g2[i]);
             NodeP a    = g2[i].relations[0].Up;
             NodeP b    = g2[i].relations[1].Up;
             Edge  ed   = new Edge(a, b, "p");
             bool  esta = false;
             foreach (Edge eee in g2.EdgesList)
             {
                 //si ya esta
                 if ((ed.Origin.Name == eee.Origin.Name && ed.Destiny.Name == eee.Destiny.Name) || (ed.Origin.Name == eee.Destiny.Name && ed.Destiny.Name == eee.Origin.Name))
                 {
                     esta = true;
                 }
             }
             if (!esta)
             {
                 g2.EdgesList.Add(ed);
                 a.InsertRelation(b, 1, false);
                 b.InsertRelation(a, 1, false);
             }
             g2.RemoveNode(g2[i--]);
         }
     }
 }
Example #2
0
        private void tryEveryNodeK33(Graph g2, List <NodeP> nods)
        {
            List <NodeP>         tempRel;
            List <List <NodeP> > grupos = null;
            NodeP tempNode;

            if (checkHomeomorphicK33(g2))
            {
                grupos = equalToK33(g2);
                if (grupos != null && nods.Count == 0)
                {
                    foreach (List <NodeP> lnp in grupos)
                    {
                        foreach (NodeP np in lnp)
                        {
                            nods.Add(np);
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < g2.Count; i++)
                    {
                        tempRel  = getSurroundNodes(g2[i]);
                        tempNode = new NodeP(g2[i]);
                        g2.RemoveNode(g2[i]);

                        // llamada recursiva
                        tryEveryNodeK33(g2, nods);
                        // unir nodos otra vez
                        tempNode.Degree = 0;
                        g2.Insert(i, tempNode);
                        //g2.Add(tempNode);
                        for (int j = 0; j < tempRel.Count; j++)
                        {
                            tempRel[j].InsertRelation(tempNode, j, false);
                            tempNode.InsertRelation(tempRel[j], j, false);
                            g2.EdgesList.Add(new Edge(tempNode, tempRel[j], "e" + j.ToString()));
                        }
                    }
                }
            }
        }