Select Git revision
-
Luigi Santocanale authoredLuigi Santocanale authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
Main.java 3.14 KiB
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Random;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
public class MainStub {
@SuppressWarnings("unused")
private final static Random gen = new Random();
public static ArrayList<Edge> genTree(Graph graph) {
ArrayList<Edge> randomTree;
// TOOO : modifier l'algorithme utiliser ici.
// Non-random BFS
ArrayList<Arc> randomArcTree =
BreadthFirstSearch.generateTree(graph,0);
randomTree = new ArrayList<>();
for (Arc a : randomArcTree) randomTree.add(a.support);
return randomTree;
}
public static void main(String argv[]) throws InterruptedException {
Grid grid = null;
grid = new Grid(1920/11,1080/11);
Graph graph = grid.graph;
// Graph graph = new Complete(400).graph;
// Graph graph = new ErdosRenyi(1_000, 100).graph;
// Graph graph = new Lollipop(1_000).graph;
int nbrOfSamples = 10;
int diameterSum = 0;
double eccentricitySum = 0;
long wienerSum = 0;
int degreesSum[] = {0, 0, 0, 0, 0};
int degrees[];
ArrayList<Edge> randomTree = null;
RootedTree rooted = null;
long startingTime = System.nanoTime();
for (int i = 0; i < nbrOfSamples; i++) {
randomTree= genTree(graph);
rooted = new RootedTree(randomTree,0);
// rooted.printStats();
diameterSum = diameterSum + rooted.getDiameter();
eccentricitySum = eccentricitySum + rooted.getAverageEccentricity();
wienerSum = wienerSum + rooted.getWienerIndex();
degrees = rooted.getDegreeDistribution(4);
for (int j = 1; j < 5; j++) {
degreesSum[j] = degreesSum[j] + degrees[j];
}
}
long delay = System.nanoTime() - startingTime;