www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

GrapheEcart.cpp (1655B)


      1 #include "GrapheEcart.h"
      2 
      3 GrapheEcart::GrapheEcart(string nom) : Graphe(nom)
      4 {
      5 
      6 }
      7 
      8  //------- Fonctions du TP --------//
      9 //================================//
     10 
     11 /* Q1 | Retourne le graphe d'écart associé pour un flot nul.
     12 * Prerequis : le graphe doit être orienté et ne pas contenir d'ars retour. TODO revoir l'histoire de pas d'arcs retour.*/
     13 GrapheEcart::GrapheEcart(string nom, const Graphe *g) :  Graphe(nom,g)
     14 {
     15     Arc *arcInv;                                                            // Arc inverse.
     16     Arc *arc;                                                               // Arc courrant.
     17 
     18     for(unsigned int i = 0; i < g->getArcs().size(); i++)
     19         for(unsigned int j = 0; j < g->getArcs()[i].size(); j++)
     20             this->arcs[i][j]->setFlot(0);
     21 
     22     for(unsigned int i = 0; i < g->getArcs().size(); i++)
     23         for(unsigned int j = 0; j < g->getArcs()[i].size(); j++)
     24         {
     25             arc = g->getArcs()[i][j];
     26 
     27             arcInv = new Arc(arc->getS2(),arc->getS1(),0,0);
     28             arcInv->setArcRetour(true);
     29 
     30             this->ajouteArc(arcInv);
     31         }
     32 }
     33 
     34 
     35 
     36 /* Q4 | Met à jour la chaine augmentante du graphe correspondant au chemin pour une augment de k du flot.
     37 */
     38 // TODO A tester !!!
     39 void GrapheEcart::miseAJour(listeArcs_t l,int k)
     40 {
     41     Arc *arcInv;
     42 
     43     for(unsigned int i = 0; i < l.size(); i++)
     44     {
     45         l[i]->setCapacite(l[i]->getCapacite()-k);
     46         arcInv = this->arcInverse(l[i]);
     47         arcInv->setCapacite(arcInv->getCapacite()+k);
     48     }
     49 }
     50 
     51 //================================//
     52 
     53 arcs_t GrapheEcart::getListeArcs()
     54 {
     55     return this->arcs;
     56 }