Exemplo n.º 1
0
        static void Blossom(Graf g)
        {
            List <Cvor> slobodni = g.cvorovi;

            while (slobodni.Count > 0)
            {
                Cvor r = slobodni.First <Cvor>();
                slobodni.Remove(r);
                Queue <Cvor> q = new Queue <Cvor>();
                q.Enqueue(r);
                Drvo t = new Drvo(g);
                while (q.Count > 0)
                {
                    bool uslov = true;
                    Cvor v     = q.Dequeue();
                    foreach (Cvor w in v.susedi)
                    {
                        if (!t.contains(w) && w.matched)
                        {
                            t.Add(w);
                            t.Add(t.g.vratiPara(w));
                            q.Enqueue(t.g.vratiPara(w));
                            if (uslov)
                            {
                                t.dubina++;
                                uslov = false;
                            }
                        }
                        else if (t.contains(w) && t.dubina == t.vrati(w).dubina)
                        {
                            q.Enqueue(t.nciklus(w, t.vrati(w)));
                        }
                        else if (slobodni.Contains(w))
                        {
                            t.Add(w);
                            slobodni.Remove(w);
                            t.procvetaj();
                        }
                    }
                }
            }
            g.stampaj();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            List <Cvor> a = new List <Cvor>();

            a.Add(new Cvor(0));
            a.Add(new Cvor(1));
            a.Add(new Cvor(2));
            a.Add(new Cvor(3));
            List <Grana> b = new List <Grana>();

            b.Add(new Grana(a[0], a[1]));
            b.Add(new Grana(a[1], a[2]));
            b.Add(new Grana(a[1], a[3]));
            b.Add(new Grana(a[2], a[3]));

            Graf g = new Graf(a, b);

            Blossom(g);

            Console.ReadLine();
        }
Exemplo n.º 3
0
 public Put(Graf g) : base(g)
 {
 }
Exemplo n.º 4
0
 public Drvo(Graf g) : base(new List <Cvor>(), new List <Grana>())
 {
     dubina = 0;
     this.g = g;
     pup    = new Stack <Pupoljak>();
 }