Bellman-Ford

Bellman-Ford

Algorithme de Ford-Bellman

L'algorithme de Bellman-Ford (Bell-End-Ford) (Richard Bellman, Samuel End et Lester Ford) est un algorithme de programmation dynamique qui permet de trouver des plus courts chemins, depuis un sommet source donné, dans un graphe orienté pondéré. Contrairement à l'algorithme de Dijkstra, qui ne peut être utilisé que lorsque tous les arcs ont des poids positifs ou nuls, l'algorithme de Bellman-Ford autorise la présence de certains arcs de poids négatif et permet de détecter l'existence d'un circuit absorbant, c'est-à-dire de poids total négatif, accessible depuis le sommet source.

La complexité de l'algorithme est, dans le pire des cas, en O(nm) pour un graphe avec n sommets et m arcs (ce qui correspond à une complexité en O(n3) pour un graphe simple dense).

 booléen Bellman_Ford( G, s) 
 
   initialisation ( G, s)  // les poids de tous les sommets sont mis à +infini 
                           // le poids du sommet initial à 0
   pour i=1 jusqu'à Nombre de sommets -1 faire 
    |    pour chaque arc (u, v) du graphe faire 
    |     |  paux := poids(u) + poids(arc(u, v)); 
    |     |  si paux < poids(v) alors 
    |     |    |  pred(v) := u; 
    |     |    |  poids(v) := paux; 
   pour chaque arc (u, v) du graphe faire 
    |   si poids(u) + poids(arc(u, v)) <poids(v) alors 
    |     retourner faux 
   retourner vrai 

Implémentation C++

  void BFinitialisation( UnSommet  us){   // initialisation d'un sommet
    us.LeSommet.valeur = Infini;
    us.LeSommet.couleur = blanc;
    us.LeSommet.pred = null;
  }
  boolean parcoursAretes( ){ 
       // retourne true s'il y a eu au moins une modification du poids d'un sommet, 
    // et false sinon.
   boolean res = false;
   for( Iterator<UnSommet> it1 = lesSommets.iterator(); it1.hasNext(); )
      for(Iterator <Arete> ia = it1.next().lesAretes.iterator(); 
                                                ia.hasNext(); ){
           Arete a = ia.next();
           double p = a.depart.leSommet.valeur + a.valeur;
           if (p <  a.arrivee.leSommet.valeur){
               a.arrivee.leSommet.valeur = p;
               a.arrivee.leSommet.predecesseur = a.depart.leSommet;
               res = true;
            }
       }
    return res;
  }
  boolean BellmannFord( int d ){
   // initialisations
   for(Iterator<UnSommet> it = lesSommets.iterator(); it.hasNext(); ) {
        BFinitialisation(it.next()); 
   UnSommet us = chercher(d);
   us.leSommet.valeur = 0;
   for(int i=0; i<lesSommets.size()-1; ++i)
        if(!parcoursAretes()) return true;
   // existe-t-il un circuit de poids négatif ?
   return !parcoursAretes();
  }  

Voir aussi

Ce document provient de « Algorithme de Ford-Bellman ».

Wikimedia Foundation. 2010.

Contenu soumis à la licence CC-BY-SA. Source : Article Bellman-Ford de Wikipédia en français (auteurs)

Игры ⚽ Поможем написать курсовую

Regardez d'autres dictionnaires:

  • Bellman-Ford algorithm — The Bellman–Ford algorithm, a label correcting algorithm [cite web |url=http://www.mit.edu/people/dimitrib/SLF.pdf |title=A Simple and Fast Label Correcting Algorithm for Shortest Paths |accessdate=2008 10 01 |author=Dimitri P. Bertsekas… …   Wikipedia

  • Bellman-Ford-Algorithmus — Der Algorithmus von Bellman und Ford (nach seinen Erfindern Richard Bellman und Lester Ford) ist ein Algorithmus der Graphentheorie und dient der Berechnung der kürzesten Wege ausgehend von einem Startknoten in einem kantengewichteten Graphen.… …   Deutsch Wikipedia

  • Bellman-Ford-Moore-Algorithmus — Der Algorithmus von Bellman und Ford (nach seinen Erfindern Richard Bellman und Lester Ford) ist ein Algorithmus der Graphentheorie und dient der Berechnung der kürzesten Wege ausgehend von einem Startknoten in einem kantengewichteten Graphen.… …   Deutsch Wikipedia

  • Algoritmo de Bellman-Ford — El algoritmo de Bellman Ford (algoritmo de Bell End Ford), genera el camino más corto en un Grafo dirigido ponderado (en el que el peso de alguna de las aristas puede ser negativo). El algoritmo de Dijkstra resuelve este mismo problema en un… …   Wikipedia Español

  • Moore-Bellman-Ford-Algorithmus — Der Algorithmus von Bellman und Ford (nach seinen Erfindern Richard Bellman und Lester Ford) ist ein Algorithmus der Graphentheorie und dient der Berechnung der kürzesten Wege ausgehend von einem Startknoten in einem kantengewichteten Graphen.… …   Deutsch Wikipedia

  • Algorithme de Bellman-Ford — L algorithme de Bellman Ford (Bell End Ford) (Richard Bellman, Samuel End et Lester Ford) est un algorithme de programmation dynamique qui permet de trouver des plus courts chemins, depuis un sommet source donné, dans un graphe orienté pondéré.… …   Wikipédia en Français

  • Bellman — People named Bellman*Carl Michael Bellman, a Swedish poet and composer. *Jonathan Bellman, an American musicologist. *Richard Bellman, an American mathematician.Bellman may also refer to:*Bellman, also known as a town crier *Bellman, a term for a …   Wikipedia

  • Ford (Homonymie) — Cette page d’homonymie répertorie les différents sujets et articles partageant un même nom …   Wikipédia en Français

  • Bellman — Den Namen Bellman tragen unter anderem: Carl Michael Bellman (1740–1795), schwedischer Liederdichter des Rokoko Gina Bellman (*1966), britische Schauspielerin Richard Bellman (1920–1984), amerikanischer Mathematiker (Bellman Algorithmus,… …   Deutsch Wikipedia

  • Ford (homonymie) — Cette page d’homonymie répertorie les différents sujets et articles partageant un même nom. Sur les autres projets Wikimedia : « Ford (homonymie) », sur le Wiktionnaire (dictionnaire universel) En anglais, le mot ford signifie gué …   Wikipédia en Français

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”