Package labyrinthe

Examples of labyrinthe.VertexInterface


  private PreviousInterface dijkstra( GraphInterface g, VertexInterface r, ASetInterface A, PiInterface pi, PreviousInterface previous) {
   
    ArrayList<VertexInterface> vertexList = g.getAllVertices();
    int n = vertexList.size();// n = ordre du graph
    VertexInterface pivot = r;
    boolean continuer = true; // Permet de sortir de la boucle lorsque pivot est null, ce qui arrive lorsqu'aucun chemin de va de D à A.
    int i;
   
   
    //initialisation de pi
    for(i = 0 ; i < n ; i++) {
      pi.setPi(vertexList.get(i), -1);
    }
    pi.setPi(r, 0);
   
    i = 0;
    while(i < n - 1 && continuer) {
     
     
      ArrayList<VertexInterface> listNextVertex = pivot.getNext();
     
      if(listNextVertex != null) {
     
        for(int j = 0 ; j < listNextVertex.size() ; j++) {
          VertexInterface successeurPivot = listNextVertex.get(j);
         
          if(!A.isInA(successeurPivot)) {
            if(pi.getPi(pivot) + g.getWeight(pivot, successeurPivot) < pi.getPi(successeurPivot) || pi.getPi(successeurPivot) == -1) {
              pi.setPi(successeurPivot, pi.getPi(pivot) + g.getWeight(pivot, successeurPivot));
              previous.setPrevious(successeurPivot, pivot);
            }
          }
 
        }
      } else {
        System.out.println("Null !!");
      }

      //recherche du min de pi(y) pour y dans G\A :
      int min = -1; // -1 <=> +infinity
      VertexInterface minVertex = null;
      for(int j = 0 ; j < n ; j++) {
        VertexInterface currentVertex = vertexList.get(j);

        if(!A.isInA(currentVertex)) {
          if(pi.getPi(currentVertex) != -1 && (min > pi.getPi(currentVertex) || min == -1)) {
            min = pi.getPi(currentVertex);
            minVertex = currentVertex;
View Full Code Here


  }
 
  public ArrayList<VertexInterface> getShortestPathsTo(VertexInterface x)
  {
    ArrayList<VertexInterface> path = new ArrayList<VertexInterface>();
    VertexInterface y = x;
   
    try {
     
      while(this.getPrevious(y) != null) {
        VertexInterface sommetPrecedent = this.getPrevious(y);
        path.add(sommetPrecedent);
        y = sommetPrecedent;
      }
      return path;
     
View Full Code Here

TOP

Related Classes of labyrinthe.VertexInterface

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.