public MazeStruct DrawMazeSkelethOfSize(int MazeSize,bool is_fivedirect)
        {
            EdgeWeightedGraph MazeBasic = new EdgeWeightedGraph(MazeSize * MazeSize);
                //  int tab[25];
                Random rand;
                rand = new Random();
                int xRand = rand.Next();
                for (int i = 0; i < MazeSize; i++)
                {
                    for (int j = 0; j < MazeSize; j++)
                    {
                        //  for(int x=0;x<4;x++)
                        int dest = ((i + 1) * MazeSize) + j;
                        if (i + 1 < MazeSize)
                        {
                            xRand = (rand.Next() % 6) + 1;
                            Edge tempEdge = new Edge(i * MazeSize + j, dest, xRand);
                            MazeBasic.AddEdge(tempEdge);
                        }

                        dest = ((i - 1) * MazeSize) + j;
                        if (i - 1 >= 0)
                        {
                            xRand = (rand.Next() % 6) + 1;
                            Edge tempEdge = new Edge(i * MazeSize + j, dest, xRand);
                            MazeBasic.AddEdge(tempEdge);
                        }

                        dest = (i * MazeSize) + (j + 1);
                        if (j + 1 < MazeSize)
                        {
                            xRand = (rand.Next() % 6) + 1;
                            Edge tempEdge = new Edge(i * MazeSize + j, dest, xRand);
                            MazeBasic.AddEdge(tempEdge);
                        }

                        dest = (i * MazeSize) + (j - 1);
                        if (j - 1 >= 0)
                        {
                            xRand = (rand.Next() % 6) + 1;
                            Edge tempEdge = new Edge(i * MazeSize + j, dest, xRand);
                            MazeBasic.AddEdge(tempEdge);
                        }

                        if (is_fivedirect)
                        {
                            dest = ((i + 1) * MazeSize) + (j + 1);
                            if (j + 1 < MazeSize && i + 1 < MazeSize)
                            {
                                xRand = (rand.Next() % 6) + 1;
                                Edge tempEdge = new Edge(i * MazeSize + j, dest, xRand);
                                MazeBasic.AddEdge(tempEdge);
                            }
                        }

                    }
                }

                PrimMST MazeBasicTree = new PrimMST(MazeBasic);
                //   MazeBasicTree.Edges
                Queue<Edge> MazeDone = new Queue<Edge>();
               // Queue<Edge> MazeDone = new Queue<Edge>();

              //  int sorc, desto;
              //  String writelienString;
                MazeStruct MazeToReturn;
                MazeToReturn = new MazeStruct(MazeSize* MazeSize);
                foreach (Edge s in MazeBasicTree.Edges())
                {

                    // Debug.WriteLine( s.Target.  +"  ");

                    MazeToReturn.setUpByEdge(s,true);

                }
                return MazeToReturn;
        }
        public void DrawSkelethMaze()
        {
            EdgeWeightedGraph MazeBasic = new EdgeWeightedGraph(25);
              //  int tab[25];
                Random rand;
                    rand = new Random();
                    int xRand = rand.Next();
                for(int i=0;i<5;i++)
                {
                    for (int j = 0; j < 5; j++)
                    {
                        //  for(int x=0;x<4;x++)
                        int dest = ((i + 1) * 5) + j;
                        if (i + 1 < 5)
                        {
                            xRand = (rand.Next() % 6) + 1;
                            Edge tempEdge = new Edge(i * 5 + j, dest, xRand);
                            MazeBasic.AddEdge(tempEdge);
                        }

                        dest = ((i - 1) * 5) + j;
                        if (i - 1 >= 0)
                        {
                            xRand = (rand.Next() % 6) + 1;
                            Edge tempEdge = new Edge(i * 5 + j, dest, xRand);
                            MazeBasic.AddEdge(tempEdge);
                        }

                        dest = (i * 5) + (j + 1);
                        if (j + 1 < 5)
                        {
                            xRand = (rand.Next() % 6) + 1;
                            Edge tempEdge = new Edge(i * 5 + j, dest, xRand);
                            MazeBasic.AddEdge(tempEdge);
                        }

                        dest = (i * 5) + (j - 1);
                        if (j - 1 >= 0)
                        {
                            xRand = (rand.Next() % 6) + 1;
                            Edge tempEdge = new Edge(i * 5 + j, dest, xRand);
                            MazeBasic.AddEdge(tempEdge);
                        }

                        dest =( (i + 1) * 5) + (j + 1);
                        if( j + 1 < 5  && i + 1 < 5)
                        {
                            xRand = (rand.Next() % 6) + 1;
                            Edge tempEdge = new Edge(i * 5 + j, dest, xRand);
                            MazeBasic.AddEdge(tempEdge);
                        }

                    }
                }

                    PrimMST MazeBasicTree = new PrimMST(MazeBasic);
                 //   MazeBasicTree.Edges
                        Queue<Edge> MazeDone = new Queue<Edge>();

                    int sorc,desto;
                    String writelienString;
                   foreach (Edge s in MazeBasicTree.Edges())
            {

               // Debug.WriteLine( s.Target.  +"  ");

                       sorc = s.Source();
                       desto = s.Dest();
                       writelienString = sorc.ToString() + "  " + desto.ToString();

                  //     Debug.WriteLine(writelienString);

            }
        }
        public void DrawMazeOfSize(int MazeSize)
        {
            EdgeWeightedGraph MazeBasic = new EdgeWeightedGraph(MazeSize*MazeSize);
                //  int tab[25];
                Random rand;
                rand = new Random();
                int xRand = rand.Next();
                for (int i = 0; i < MazeSize; i++)
                {
                    for (int j = 0; j < MazeSize; j++)
                    {
                        //  for(int x=0;x<4;x++)
                        int dest = ((i + 1) * MazeSize) + j;
                        if (i + 1 < MazeSize)
                        {
                            xRand = (rand.Next() % 6) + 1;
                            Edge tempEdge = new Edge(i * MazeSize + j, dest, xRand);
                            MazeBasic.AddEdge(tempEdge);
                        }

                        dest = ((i - 1) * MazeSize) + j;
                        if (i - 1 >= 0)
                        {
                            xRand = (rand.Next() % 6) + 1;
                            Edge tempEdge = new Edge(i * MazeSize + j, dest, xRand);
                            MazeBasic.AddEdge(tempEdge);
                        }

                        dest = (i * MazeSize) + (j + 1);
                        if (j + 1 < MazeSize)
                        {
                            xRand = (rand.Next() % 6) + 1;
                            Edge tempEdge = new Edge(i * MazeSize + j, dest, xRand);
                            MazeBasic.AddEdge(tempEdge);
                        }

                        dest = (i * MazeSize) + (j - 1);
                        if (j - 1 >= 0)
                        {
                            xRand = (rand.Next() % 6) + 1;
                            Edge tempEdge = new Edge(i * MazeSize + j, dest, xRand);
                            MazeBasic.AddEdge(tempEdge);
                        }

                        dest = ((i + 1) * MazeSize) + (j + 1);
                        if (j + 1 < MazeSize && i + 1 < MazeSize)
                        {
                            xRand = (rand.Next() % 6) + 1;
                            Edge tempEdge = new Edge(i * MazeSize + j, dest, xRand);
                            MazeBasic.AddEdge(tempEdge);
                        }

                    }
                }

                PrimMST MazeBasicTree = new PrimMST(MazeBasic);
                //   MazeBasicTree.Edges
                Queue<Edge> MazeDone = new Queue<Edge>();
                //  MazeDone = MazeBasicTree.Edges();

                //Edge TempEdge = new Edge(Center.Y,)
             //   int sorc, desto;
            //    String writelienString;
              //  foreach (Edge s in MazeBasicTree.Edges())
               //     {
                    // Debug.WriteLine( s.Target.  +"  ");
                //    sorc = s.Source();
             //       desto = s.Dest();
               //     writelienString = sorc.ToString() + "  " + desto.ToString();

               //     Debug.WriteLine(writelienString);

             //       }
        }