From 9cb19346dadb23e81a89cec151d43aa5fa33dc15 Mon Sep 17 00:00:00 2001 From: Loic Guegan <16000511@e003m10.istic.univ-rennes1.fr> Date: Mon, 21 Mar 2016 15:40:39 +0100 Subject: [PATCH] Ajout affichage meilleur chemin --- main/Main.java | 17 +++++++++++++++- structure/Grid.java | 49 ++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 62 insertions(+), 4 deletions(-) diff --git a/main/Main.java b/main/Main.java index 51e3c59..c1a4e1c 100644 --- a/main/Main.java +++ b/main/Main.java @@ -5,6 +5,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Set; +import org.graphstream.graph.Edge; import org.graphstream.graph.Graph; import org.graphstream.graph.implementations.SingleGraph; @@ -21,11 +22,14 @@ public class Main { Graph graph = new SingleGraph("Tutorial 1"); graph.addAttribute("ui.stylesheet", "url('resources/style.css')"); + ArrayList grid=g.getGrid(); for(Router r : grid){ graph.addNode(r.name); } + + ArrayList bestLink=g.getLinks().get(g.getBestLinkIndex()); for(Router r : grid){ String current=r.name; HashMap relier=r.getLinks(); @@ -36,8 +40,17 @@ public class Main { String currentRouterName=currentRouter.name; try{ //graph.addEdge(current+currentRouter, current, currentRouter).addAttribute("ui.style", "fill-color: rgb(0,100,255);"); - graph.addEdge(current+currentRouterName, current, currentRouterName).setAttribute("ui.label", relier.get(currentRouter)); + + if(g.isEdgeOfLink(bestLink, r, currentRouter)){ + Edge toAdd=graph.addEdge(current+currentRouterName, current, currentRouterName); + toAdd.setAttribute("ui.label", relier.get(currentRouter)); + toAdd.setAttribute("ui.style", "fill-color:red;"); + }else{ + graph.addEdge(current+currentRouterName, current, currentRouterName).setAttribute("ui.label", relier.get(currentRouter)); + + } + } @@ -48,6 +61,8 @@ public class Main { } } + g.printLinkWeight(); + graph.display(); } } diff --git a/structure/Grid.java b/structure/Grid.java index eb76638..bd0af2a 100644 --- a/structure/Grid.java +++ b/structure/Grid.java @@ -131,7 +131,7 @@ public class Grid { return currentBestLink; } - private int getMaxBottleneck(ArrayList link){ + /*private int getMaxBottleneck(ArrayList link){ int max=this.getWeigthOfLink(link.get(0), link.get(1)); for(int j=1;j link){ + int max=this.getWeigthOfLink(link.get(0), link.get(1)); + for(int j=1;jcurrentMax){ + max=currentMax; + } + } return max; } @@ -153,14 +164,46 @@ public class Grid { ArrayList link=this.links.get(i); System.out.print("Link number " + i + " ==> "); for(int j=0;jlink, Router src, Router dest){ + for(int j=0;j getGrid() { return grid; }