routage-optimiste/main/Main.java

55 lines
1.3 KiB
Java
Raw Normal View History

2016-02-23 13:34:10 +01:00
package main;
2016-03-18 11:16:47 +01:00
import java.awt.RenderingHints.Key;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
2016-03-14 20:30:30 +01:00
import org.graphstream.graph.Graph;
import org.graphstream.graph.implementations.SingleGraph;
2016-03-14 18:02:24 +01:00
import structure.Grid;
2016-03-18 11:16:47 +01:00
import structure.Router;
2016-03-14 16:35:31 +01:00
2016-02-23 13:34:10 +01:00
public class Main {
public static void main(String[] args) {
2016-03-14 18:02:24 +01:00
Grid g=new Grid();
2016-03-18 11:16:47 +01:00
//g.printLinkWeight();
// System.out.println("Best link : " + g.getBestLinkIndex());
2016-03-14 20:30:30 +01:00
Graph graph = new SingleGraph("Tutorial 1");
2016-03-18 11:16:47 +01:00
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));
2016-03-14 20:30:30 +01:00
2016-03-18 11:16:47 +01:00
}
catch(Exception e){
// System.out.println("Bug de merde.");
}
}
}
graph.display();
2016-02-23 13:34:10 +01:00
}
}