/**
   * Método para hacer el código a partir del contenido de los vértices en el
   * grafo.
   */
  public boolean make() {

    boolean codeGenerated = false;

    for (int i = 0; i < graphs.size(); i++) {
      g = graphs.get(i);

      if (i == 0) {
        addGlobalVariables(g);
      }

      vertices = g.getVertices();
      edges = g.getEdges();
      head = g.getHead();

      if (head == null) {
        continue;
      }

      if (g.getNumVertices() > 0) {
        recurse(head);
        codeGenerated = true;
      } else {
        codeGenerated = false;
      }
    }

    return codeGenerated;
  }
예제 #2
0
파일: Main.java 프로젝트: michalkurzeja/ASD
  public static void main(String[] args) throws Exception {
    Graph<Integer> graph = new Graph<Integer>(new ListStorage<>());

    //        CSVImporter.importGraph(graph, "src/Test/graf.txt");

    Vertex v1 = graph.addVertex(1);
    Vertex v2 = graph.addVertex(2);
    Vertex v3 = graph.addVertex(3);

    graph.addEdge(v1, v2);
    graph.addEdge(v1, v3);
    graph.addEdge(v2, v3);

    Edge[] edges = graph.getEdges();

    System.out.println(String.format("Are neighbours: %b", graph.areNeighbours(v1, v2)));

    Edge[] path = graph.findPath(v1, v3);
  }