Commit 86b7ac42 authored by Corentin Bettiol's avatar Corentin Bettiol 💻

remove redundancy

parent bd8e8c6f
......@@ -131,6 +131,7 @@ void Graph::minArcDispo(int *current, int *pere){
// sauvegarde de distance, from, to, indexArc
int min[4] = {MAX_VAL};
// exploration des arcs
for(int i(0); i<arc.size(); i++){
if(arc[i][3] == 1){
......@@ -225,4 +226,13 @@ int Graph::getIdByNode(int n){
// récupère le nom du nœud passé en argument
int Graph::getNodeById(int id){
return node[id];
}
// affiche les chemins les plus courts de p au début
// récursif
void Graph::display_shortest_paths(int p){
if(pere[pere[p]] != pere[p])
display_shortest_paths(pere[p]);
cout << node[pere[p]] << "->" << node[p] << ": " << d[p] - d[pere[p]] << " (" << d[p] << ")" << endl;
}
\ No newline at end of file
......@@ -31,6 +31,7 @@
int getIdByNode(int);
int getNodeById(int);
void setFutureNodesToTrue(int);
void display_shortest_paths(int);
};
#endif
......@@ -45,6 +45,19 @@ int main(){
cout << "\n\npcc:\n>>>" << d << endl;
cout << "\nshortest path:" << endl;
g.display_shortest_paths(g.getIdByNode(10));
d = g.MooreDijkstra(3,8);
cout << "\n\npcc:\n>>>" << d << endl;
cout << "\nshortest path:" << endl;
g.display_shortest_paths(g.getIdByNode(8));
return 0;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment