observer dijkstra
This commit is contained in:
		
							parent
							
								
									4e6a6cbcd3
								
							
						
					
					
						commit
						ce9743650b
					
				
					 1 changed files with 9 additions and 3 deletions
				
			
		|  | @ -34,10 +34,12 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm { | |||
|         Label label_dest =tab.get(data.getDestination().getId()); | ||||
|         /*insertion de label origine dans le tas */ | ||||
|         tas.insert(label_origine); | ||||
|         notifyOriginProcessed(label_origine.getSommet()); | ||||
|         Label x; | ||||
|         while (label_dest.getMarque()==false && tas.isEmpty()==false) { | ||||
|             x=tas.deleteMin(); | ||||
|             x.setMarque(true); | ||||
|             notifyNodeMarked(x.getSommet()); | ||||
|             for (Arc suc:x.getSommet().getSuccessors() ) { | ||||
|                 int index=suc.getDestination().getId(); | ||||
|                 if (!tab.get(index).getMarque()) { | ||||
|  | @ -47,11 +49,16 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm { | |||
|                             tas.remove(tab.get(index)); | ||||
|                         } catch (Exception e) { | ||||
|                             System.out.println("l'élement n'est pas dans la tas"); | ||||
|                             notifyNodeReached(tab.get(index).getSommet()); | ||||
|                             if(tab.get(index).getSommet().equals(data.getDestination())){ | ||||
|                                 notifyDestinationReached(tab.get(index).getSommet()); | ||||
|                             } | ||||
|                         } | ||||
|                         tab.get(index).setCoutmin(x.getCost()+suc.getLength()); | ||||
|                         tab.get(index).setPere(suc); | ||||
|                         /*insertion dans le tas */ | ||||
|                         tas.insert(tab.get(index)); | ||||
|                         tas.insert(tab.get(index));             | ||||
|                         // The destination has been found, notify the observers. | ||||
|                     } | ||||
| 
 | ||||
|                 } | ||||
|  | @ -63,8 +70,7 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm { | |||
|         } | ||||
|         else { | ||||
| 
 | ||||
|             // The destination has been found, notify the observers. | ||||
|             notifyDestinationReached(data.getDestination()); | ||||
| 
 | ||||
| 
 | ||||
|             ArrayList<Arc> arcs = new ArrayList<>(); | ||||
|             Arc arc = label_dest.getPere(); | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue