aboutsummaryrefslogtreecommitdiff
path: root/main/Main.java
diff options
context:
space:
mode:
Diffstat (limited to 'main/Main.java')
-rw-r--r--main/Main.java48
1 files changed, 38 insertions, 10 deletions
diff --git a/main/Main.java b/main/Main.java
index b1e7a0a..26fcc5b 100644
--- a/main/Main.java
+++ b/main/Main.java
@@ -1,26 +1,54 @@
package main;
+import java.awt.RenderingHints.Key;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Set;
+
import org.graphstream.graph.Graph;
import org.graphstream.graph.implementations.SingleGraph;
import structure.Grid;
+import structure.Router;
public class Main {
public static void main(String[] args) {
Grid g=new Grid();
- g.printLinkWeight();
- System.out.println("Best link : " + g.getBestLinkIndex());
+ //g.printLinkWeight();
+ // System.out.println("Best link : " + g.getBestLinkIndex());
+
Graph graph = new SingleGraph("Tutorial 1");
+
+ ArrayList<Router> grid=g.getGrid();
+ ArrayList<ArrayList<Integer>> links=g.getLinks();
+ for(Router r : grid){
+ graph.addNode(r.name);
+
+ }
+ for(Router r : grid){
+ String current=r.name;
+ HashMap<Router, Integer> relier=r.getLinks();
+ Set k=relier.keySet();
+ Iterator<Router> i=k.iterator();
+ while(i.hasNext()){
+ Router currentRouter=i.next();
+ 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));
+
- graph.addNode("A");
- graph.addNode("B");
- graph.addNode("C");
- graph.addEdge("AB", "A", "B");
- graph.addEdge("BC", "B", "C");
- graph.addEdge("CA", "C", "A");
- graph.getEdge(0).addAttribute("ui.style", "fill-color: red;");
- graph.display(false);
+ }
+ catch(Exception e){
+ // System.out.println("Bug de merde.");
+ }
+
+ }
+
+ }
+ graph.display();
}
}