public virtual void readXMLgraph(string fpath)
 {
     XmlTextReader reader = new XmlTextReader(fpath);
     Nodo nodo = new Nodo(0, 0, 0);
     Arco arco = new Arco(0, 0, 0, 0);
     int temp;
     while (reader.Read())
     {
         if (reader.Name == "nodo")
         {
             while (reader.MoveToNextAttribute())
             {
                 switch (reader.Name)
                 {
                     case "id":
                         nodo.id = Convert.ToInt16(reader.Value);
                         break;
                     case "x":
                         nodo.x = Convert.ToInt16(reader.Value);
                         break;
                     case "y":
                         nodo.y = Convert.ToInt16(reader.Value);
                         break;
                 }
             }
             V.Add(nodo);
             numNodi++;
         }
         if (reader.Name == "arco")
         {
             while (reader.MoveToNextAttribute())
             {
                 switch (reader.Name)
                 {
                     case "id":
                         arco.id = Convert.ToInt16(reader.Value);
                         break;
                     case "end1":
                         arco.end1 = Convert.ToInt16(reader.Value);
                         break;
                     case "end2":
                         arco.end2 = Convert.ToInt16(reader.Value);
                         break;
                     case "type":
                         if (reader.Value == "Edge")
                             isOr = true;
                         break;
                     case "w":
                         arco.w = Convert.ToInt16(reader.Value);
                         break;
                 }
             }
             E.Add(arco);
             if (isOriented)
             {
                 temp = arco.end1;
                 arco.end1 = arco.end2;
                 arco.end2 = temp;
                 E.Add(arco);
                 numArchi++;
                 isOr = false;
             }
             numArchi++;
         }
     }
     reader.Close();
 }
        public virtual List<int> kruskal()
        {
            UpTree myUT = new UpTree(numNodi);
            List<Arco> E1 = new List<Arco>();
            List<int> A = new List<int>();

            for (int i = 0; i < numNodi; i++)
                myUT.makeSet(V[i].id);

            #region Edge sort
            XmlTextReader reader = new XmlTextReader("Grafo.xml");
            Nodo nodo = new Nodo(0, 0, 0);
            Arco arco = new Arco(0, 0, 0, 0);
            while (reader.Read())
            {
                if (reader.Name == "arco")
                {
                    while (reader.MoveToNextAttribute())
                    {
                        switch (reader.Name)
                        {
                            case "id":
                                arco.id = Convert.ToInt16(reader.Value);
                                break;
                            case "end1":
                                arco.end1 = Convert.ToInt16(reader.Value);
                                break;
                            case "end2":
                                arco.end2 = Convert.ToInt16(reader.Value);
                                break;
                            case "w":
                                arco.w = Convert.ToInt16(reader.Value);
                                break;
                        }
                    }
                    E1.Add(arco);
                }
            }
            reader.Close();
            IEnumerable<Arco> temp = E1.OrderBy(arc => arc.w);
            E1 = temp.ToList();
            #endregion

            for (int i = 0; i < E1.Count; i++)
            {
                if (myUT.findSet(E1[i].end1) != myUT.findSet(E1[i].end2))
                {
                    A.Add(E1[i].id);
                    myUT.union(E1[i].end1, E1[i].end2);
                }
            }

            return A;
        }