Skip to main content
Sign in
Snippets Groups Projects
Commit d1c7b8a8 authored by Luigi Santocanale's avatar Luigi Santocanale
Browse files

Everything commited

parent f80dce49
No related branches found
No related tags found
No related merge requests found
Showing
with 401 additions and 174 deletions
# Default ignored files
/shelf/
/workspace.xml
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<ScalaCodeStyleSettings>
<option name="MULTILINE_STRING_CLOSING_QUOTES_ON_NEW_LINE" value="true" />
</ScalaCodeStyleSettings>
</code_scheme>
</component>
\ No newline at end of file
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_13" project-jdk-name="13" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/tp3-git.iml" filepath="$PROJECT_DIR$/tp3-git.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
\ No newline at end of file
# Cible qui pour compiler
# Le nom de votre classe principale
# Renommez si nécessaire
MAINCLASS=Main
## Le chemin vers où votre classe compilée est installée
# Renommez si nécessaire
INSTALLDIR=out/production/TP3
all: compile install exec
# Cible pour compiler
compile:
cd src ; make compile
install:
cd src ; make install
clean:
cd src ; make clean ; make cleanInstall
rm *.zip
# Cible qui explique comment executer
exec:
java -classpath $(INSTALLDIR) $(MAINCLASS)
# Demarre automatiquement une demonstration de votre programme
# Il faut que cette demo soit convaincante
demo:
java -classpath $(INSTALLDIR) $(MAINCLASS)
# Executer automatiquent les test
# On s'attend (d'habitude) que pour claque classe MaClasse il y ait une
# classe TestMaClasse qui vorifie le bon comportment de chaque methode de la classe
# sur au moins une entrée
# A vous de completer
test:
# Pour la cible suivante, on vous laisse faire
clean:
# Cible pour créer son rendu de tp
zip:
moi=$$(whoami) ; zip -r $${moi}_renduTP2.zip *
# Cible pour vérifier le contenu de son rendu de tp
zipVerify:
moi=$$(whoami) ; unzip -l $${moi}_renduTP2.zip
No preview for this file type
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
public class Graph implements Iterable<Edge>{
// classe de graphe non orientés permettant de manipuler
// en même temps des arcs (orientés)
// pour pouvoir stocker un arbre couvrant, en plus du graphe
int order;
int edgeCardinality;
ArrayList<LinkedList<Edge>> adjacency;
ArrayList<LinkedList<Arc>> inAdjacency;
ArrayList<LinkedList<Arc>> outAdjacency;
public boolean isVertex(int index) {
// à remplir
}
public <T> ArrayList<LinkedList<T>> makeList(int size) {
ArrayList<LinkedList<T>> res = new ArrayList<>(size);
for(int i = 0; i <= size; i++) {
res.add(null);
}
return res;
}
public Graph(int upperBound) {
// à remplir
}
public void addVertex(int indexVertex) {
// à remplir
}
public void ensureVertex(int indexVertex) {
// à remplir
}
public void addArc(Arc arc) {
// à remplir
}
public void addEdge(Edge e) {
// à remplir
}
}
package Graphs;
public class Arc {
Edge support;
public Edge support;
boolean reversed;
public Arc(Edge e, boolean reversed) {
......
......
package Graphs;
public class Edge implements Comparable<Edge> {
protected int source;
protected int dest;
public int source;
public int dest;
double weight;
public Edge(int source, int dest, double weight) {
......
......
package Graphs;
import java.util.ArrayList;
import java.util.LinkedList;
public class Graph {
// classe de graphe non orientés permettant de manipuler
// en même temps des arcs (orientés)
// pour pouvoir stocker un arbre couvrant, en plus du graphe
public int order;
int edgeCardinality;
ArrayList<LinkedList<Edge>> adjacency;
ArrayList<LinkedList<Arc>> inAdjacency;
ArrayList<LinkedList<Arc>> outAdjacency;
public Graph(int upperBound) {
// à remplir
}
public boolean isVertex(int index) {
// à remplir
return true;
}
public void addVertex(int indexVertex) {
// à remplir
}
public void ensureVertex(int indexVertex) {
// à remplir
}
public void addArc(Arc arc) {
// à remplir
}
public void addEdge(Edge e) {
// à remplir
}
public Arc[] outNeighbours(int sommet) {
// à remplir
return outAdjacency.get(sommet).toArray(new Arc[0]);
}
}
package Graphs.GraphClasses;
import Graphs.* ;
public class Complete {
Graph graph;
public Graph graph;
public Complete(int order) {
this.graph = new Graph(order);
......
......
package Graphs.GraphClasses;
import Graphs.* ;
import RandomTreeAlgos.BreadthFirstSearch;
import java.util.ArrayList;
import java.util.Random;
......@@ -5,7 +9,7 @@ import java.util.Random;
public class ErdosRenyi {
private final static Random gen = new Random();
Graph graph;
public Graph graph;
private int order;
private double edgeProbability;
......
......
package Graphs.GraphClasses;
import Graphs.*;
import java.util.BitSet;
......@@ -7,7 +10,7 @@ public class Grid {
int height;
int maxVertex;
Graph graph;
public Graph graph;
public int abscissaOfVertex(int vertex) {
return vertex % width;
......
......
package Graphs.GraphClasses;
import Graphs.*;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GradientPaint;
......
......
package Graphs.GraphClasses;
import Graphs.*;
import java.util.ArrayList;
import java.util.Collections;
public class Lollipop {
Graph graph;
public Graph graph;
public Lollipop(int order) {
graph = new Graph(order);
......
......
package Graphs;
import RandomTreeAlgos.BreadthFirstSearch;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
......
......
import java.awt.image.BufferedImage;
import Graphs.*;
import Graphs.GraphClasses.*;
import RandomTreeAlgos.BreadthFirstSearch;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Random;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
public class MainStub {
public class Main {
@SuppressWarnings("unused")
private final static Random gen = new Random();
public static ArrayList<Edge> genTree(Graph graph) {
ArrayList<Edge> randomTree;
static Grid grid = null;
// 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);
public static void main(String argv[]) throws InterruptedException {
Graph graph = chooseFromGraphFamily();
ArrayList<Edge> randomTree = null;
return randomTree;
int noOfSamples = 10;
Stats stats = new Stats(noOfSamples);
for (int i = 0; i < noOfSamples; i++) {
randomTree = genTree(graph);
stats.update(randomTree);
}
stats.print();
if (grid != null) showGrid(grid, randomTree);
}
public static void main(String argv[]) throws InterruptedException {
private static Graph chooseFromGraphFamily() {
// Parametriser ici cette fonction afon de pouvoir choisir
// quelle classe de graohe utiliser
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;
return grid.graph;
}
int nbrOfSamples = 10;
int diameterSum = 0;
double eccentricitySum = 0;
long wienerSum = 0;
int degreesSum[] = {0, 0, 0, 0, 0};
int degrees[];
public static ArrayList<Edge> genTree(Graph graph) {
ArrayList<Edge> randomTree;
ArrayList<Edge> randomTree = null;
RootedTree rooted = null;
// TOOO : modifier l'algorithme utilisé ici
// ou bien parametriser à l'aide de la ligne de commande
long startingTime = System.nanoTime();
for (int i = 0; i < nbrOfSamples; i++) {
randomTree= genTree(graph);
// Non-random BFS
ArrayList<Arc> randomArcTree =
BreadthFirstSearch.generateTree(graph, 0);
randomTree = new ArrayList<>();
for (Arc a : randomArcTree) randomTree.add(a.support);
return randomTree;
}
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];
}
private static class Stats {
public int nbrOfSamples = 10;
private int diameterSum = 0;
private double eccentricitySum = 0;
private long wienerSum = 0;
private int degreesSum[] = {0, 0, 0, 0, 0};
private int degrees[];
long startingTime = 0;
public Stats(int noOfSamples) {
int nbrOfSamples = noOfSamples;
long startingTime = System.nanoTime();
}
public void print() {
long delay = System.nanoTime() - startingTime;
System.out.println("On " + nbrOfSamples + " samples:");
......@@ -82,15 +91,29 @@ public class MainStub {
System.out.println("Average computation time: "
+ delay / (nbrOfSamples * 1_000_000) + "ms");
}
public void update(ArrayList<Edge> randomTree) {
RootedTree 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];
}
}
if (grid != null) showGrid(grid,rooted,randomTree);
}
private static void showGrid(
Grid grid,
RootedTree rooted,
ArrayList<Edge> randomTree
) throws InterruptedException {
RootedTree rooted = new RootedTree(randomTree, 0);
JFrame window = new JFrame("solution");
final Labyrinth laby = new Labyrinth(grid, rooted);
......@@ -113,13 +136,12 @@ public class MainStub {
window.setVisible(true);
// Pour générer un fichier image.
// try {
// laby.saveImage("resources/random.png");
// } catch (IOException e1) {
// e1.printStackTrace();
// }
try {
laby.saveImage("resources/random.png");
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment