public void escreverArvore() throws IOException {
        //Escrita dos ios
        FileWriter writer = new FileWriter(new File(dir, "arvoreGeradora.txt"));
        PrintWriter saida = new PrintWriter(writer, true);


        for (int i = 0; i < grafo.arvoreGeradora.size(); i++) {
            ArrayList els = grafo.arvoreGeradora.get(i);
            for (int j = 0; j < els.size(); j++) {
                int vertice = Integer.parseInt(els.get(j).toString());
                if (grafo.busca.equals("BFS")) {
                    if (grafo.modo_de_representacao == 'l') {
                        int index = vertice - 1;
                        Vertex vertex = (Vertex) grafo.vertices.get(index);
                        saida.print("{\"vertice\": " + vertex.oid + ", \"pai\": " + vertex.pai + ", \"nivel\":" + vertex.nivel + " }, ");
                    } else if (grafo.modo_de_representacao == 'm') {
                        int ind = vertice - 1;
                        saida.print("{\"vertice\": " + vertice + ", \"pai\": " + grafo.pais.get(ind).toString() + ", \"nivel\":" + grafo.niveis.get(ind).toString() + " }, ");
                    }
                } else if (grafo.busca.equals("DFS")) {
                    if (grafo.modo_de_representacao == 'l') {
                        Vertex vertex = (Vertex) els.get(j);
                        saida.print("|" + vertex.oid + "/" + vertex.pai + "/" + vertex.nivel + "| ");
                    } else if (grafo.modo_de_representacao == 'm') {
                        int ind = vertice - 1;
                        saida.print("|" + vertice + "/" + grafo.pais.get(ind).toString() + "/" + grafo.niveis.get(ind).toString() + "| ");
                    }

                }
            }
            saida.println();
            saida.println();
        }

        saida.close();
        writer.close();
    }