diff --git a/main/Main.java b/main/Main.java index 64a8858..e6e6c20 100644 --- a/main/Main.java +++ b/main/Main.java @@ -3,19 +3,14 @@ package main; import org.graphstream.graph.*; import org.graphstream.graph.implementations.*; +import structure.Grid; + public class Main { public static void main(String[] args) { - Graph graph = new SingleGraph("Tutorial 1"); - - 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.display(); + Grid g=new Grid(5, 6,25); + g.displayGrid(); + } } diff --git a/structure/Grid.java b/structure/Grid.java index cdf21f4..bb3f30d 100644 --- a/structure/Grid.java +++ b/structure/Grid.java @@ -1,5 +1,44 @@ package structure; +// cedric.gueguen@irisa.fr + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.Random; + public class Grid { + private ArrayList> m_grid=new ArrayList<>(); + + public Grid(int size_x, int size_y, int max_rand){ + this.generateGrid(size_x,size_y, max_rand); + } + + + + + private void generateGrid(int size_x, int size_y, int max_rand){ + for(int x=0;x()); + for(int y=0;y> i=m_grid.iterator(); + + while(i.hasNext()){ + ArrayList current=i.next(); + Iterator j=current.iterator(); + + while(j.hasNext()){ + System.out.print(j.next() + " "); + } + System.out.println(); + } + } + }