Example #1
0
        public void DFSUtil(int v, bool[] visited, int x, int y, Grid grid, GridRepo gridRepo, Graph graph)
        {
            visited[v] = true;

            Grid  aux = gridRepo.gridRepo.ElementAt(v);
            Tuple tup;

            if (graph.isLeaf(v))
            {
                tup = aux.gridSize();
                if (x * y > tup.getX() * tup.getY())
                {
                    this.grid.setGrid(aux.grid);
                    setMinX(tup.getX());
                    setMinY(tup.getY());
                }
            }

            IEnumerator <int> i = graph.adj.ElementAt(v).GetEnumerator();
            bool hasNext        = i.MoveNext();

            while (hasNext)
            {
                int n = i.Current;
                hasNext = i.MoveNext();
                if (!visited[n])
                {
                    DFSUtil(n, visited, this.getMinX(), this.getMinY(), this.grid, gridRepo, graph);
                }
            }
        }
Example #2
0
        public void Gbfs(int parent, GridRepo gridRepo, Graph graph)
        {
            bool[] visited = new bool[graph.V];
            Grid   t       = new Grid();

            this.setMinX(8);
            this.setMinY(8);
            this.setT(t);
            GBFSUtil(parent, visited, getMinX(), getMinY(), t, gridRepo, graph);
        }
Example #3
0
        public void Dfs(int v, GridRepo gridRepo, Graph graph)
        {
            bool[] visited = new bool[graph.V];
            Grid   grid    = new Grid();

            this.setMinX(8);
            this.setMinY(8);
            this.setGrid(grid);
            DFSUtil(v, visited, getMinX(), getMinY(), grid, gridRepo, graph);
        }
Example #4
0
        public Tuple DFS(int v, GridRepo gridRepo, ResultGrid resultGrid)
        {
            DFS dfs = new DFS();

            dfs.Dfs(v, gridRepo, this);
            resultGrid.Update(dfs.grid.getGrid());
            Tuple tup = new Tuple(dfs.getMinX(), dfs.getMinY());

            return(tup);
        }
Example #5
0
        public Tuple GBFS(int v, GridRepo gridRepo, ResultGrid resultGrid)
        {
            GBFS gbfs = new GBFS();

            gbfs.Gbfs(v, gridRepo, this);
            resultGrid.Update(gbfs.getT().getGrid());
            Tuple tup = new Tuple(gbfs.getMinX(), gbfs.getMinY());

            return(tup);
        }
Example #6
0
        public int findMin(GridRepo gridRepo, int parent)
        {
            LinkedList <int> kids = this.adj.ElementAt(parent);
            int  minHeight        = 8;
            int  h;
            int  nrTab = -1;
            Grid aux;

            foreach (int nrTable in kids)
            {
                aux = gridRepo.gridRepo.ElementAt(nrTable);
                h   = tetrisHeight(aux);
                if (h < minHeight)
                {
                    minHeight = h;
                    nrTab     = nrTable;
                }
            }
            return(nrTab);
        }
Example #7
0
        public void GBFSUtil(int parent, bool[] visited, int x, int y, Grid grid, GridRepo gridRepo, Graph graph)
        {
            visited[parent] = true;

            Grid  aux = gridRepo.gridRepo.ElementAt(parent);
            Tuple tup;

            if (graph.isLeaf(parent))
            {
                tup = aux.gridSize();
                if (x * y > tup.getX() * tup.getY())
                {
                    this.getT().setGrid(aux.getGrid());
                    setMinX(tup.getX());
                    setMinY(tup.getY());
                }
            }
            else
            {
                int kid = graph.findMin(gridRepo, parent);
                GBFSUtil(kid, visited, this.getMinX(), this.getMinY(), this.getT(), gridRepo, graph);
            }
        }
Example #8
0
 public void SetGridRepo(GridRepo gridRepo)
 {
     this.gridRepo = gridRepo;
 }
Example #9
0
 public Controller(GridRepo gridRepo)
 {
     this.gridRepo = gridRepo;
     this.nr       = 1;
 }