Add interface
This commit is contained in:
parent
c444380c9a
commit
622bcc5fd7
44 changed files with 1158 additions and 13 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue