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); } } }
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); }
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); }
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); }
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); }
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); }
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); } }
public void SetGridRepo(GridRepo gridRepo) { this.gridRepo = gridRepo; }
public Controller(GridRepo gridRepo) { this.gridRepo = gridRepo; this.nr = 1; }