Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
2077955eb3 | |||
0a11547e66 | |||
b3a9cad35d | |||
a42afb9642 |
1
Graphen_Projekt.json
Normal file
1
Graphen_Projekt.json
Normal file
@ -0,0 +1 @@
|
||||
[[{"x":223,"y":338,"id":0,"art":false},{"x":353,"y":344,"id":1,"art":true},{"x":222,"y":222,"id":2,"art":false},{"x":361,"y":222,"id":3,"art":false},{"x":361,"y":476,"id":4,"art":false}],[{"n1":{"x":353,"y":344,"id":1,"art":true},"n2":{"x":223,"y":338,"id":0,"art":false},"bridge":false},{"n1":{"x":222,"y":222,"id":2,"art":false},"n2":{"x":223,"y":338,"id":0,"art":false},"bridge":false},{"n1":{"x":361,"y":222,"id":3,"art":false},"n2":{"x":222,"y":222,"id":2,"art":false},"bridge":false},{"n1":{"x":353,"y":344,"id":1,"art":true},"n2":{"x":361,"y":222,"id":3,"art":false},"bridge":false},{"n1":{"x":361,"y":222,"id":3,"art":false},"n2":{"x":223,"y":338,"id":0,"art":false},"bridge":false},{"n1":{"x":361,"y":476,"id":4,"art":false},"n2":{"x":353,"y":344,"id":1,"art":true},"bridge":true}]]
|
35
src/model/FileChooserExample.java
Normal file
35
src/model/FileChooserExample.java
Normal file
@ -0,0 +1,35 @@
|
||||
package model;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.FileChooser;
|
||||
|
||||
public class FileChooserExample extends Application {
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) {
|
||||
primaryStage.setTitle("JavaFX App");
|
||||
|
||||
FileChooser fileChooser = new FileChooser();
|
||||
|
||||
Button button = new Button("Select File");
|
||||
button.setOnAction(e -> {
|
||||
File selectedFile = fileChooser.showOpenDialog(primaryStage);
|
||||
});
|
||||
|
||||
VBox vBox = new VBox(button);
|
||||
Scene scene = new Scene(vBox, 960, 600);
|
||||
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.show();
|
||||
}
|
||||
}
|
@ -7,31 +7,128 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Graph {
|
||||
private ArrayList<Graph> values;
|
||||
|
||||
private static int[][] adjacent = { {0,1,1,1,0},
|
||||
{1,0,0,1,1},
|
||||
{1,0,0,1,0},
|
||||
{1,1,1,0,0},
|
||||
{0,1,0,0,0} };
|
||||
|
||||
private static int[][] distance = { {0,1,1,1,2},
|
||||
{1,0,2,1,1},
|
||||
{1,2,0,1,3},
|
||||
{1,1,1,0,2},
|
||||
{2,1,3,2,0} };
|
||||
|
||||
private static int[] eccentricities = {2,2,3,2,3}; // max Number from each individual Array in the distance Array
|
||||
|
||||
private static int diameter = 3; // max Number in eccentricities
|
||||
|
||||
private static int radius = 2; // half of the diameter
|
||||
|
||||
private static int center[] = {1,2,4}; // Every Knoten were eccentricities == radius
|
||||
|
||||
private static int component[][] = { {1,2,3,4}, {2,5} };
|
||||
|
||||
private static int[] articulations = {2};
|
||||
|
||||
private static int[][] bridges = {{2,5}};
|
||||
|
||||
public Graph() {
|
||||
values = new ArrayList<Graph>();
|
||||
|
||||
}
|
||||
|
||||
public boolean receiveValues() throws GraphException {
|
||||
try (BufferedReader br = new BufferedReader(new FileReader(""))) { // filePath von application.RootBorderPane.importCSV()
|
||||
String zeile;
|
||||
String[] zeilenTeile;
|
||||
String sep = ";"; // erwartetes Trennzeichen in der csv-Datei
|
||||
public static int[][] calculateAdjacent2(int[][] adjacent) {
|
||||
|
||||
int[][] adjacent2 = new int[adjacent.length][adjacent.length];
|
||||
|
||||
zeile = br.readLine(); // wenn keine Zeile gefunden, dann return null
|
||||
|
||||
while (zeile != null) {
|
||||
zeilenTeile = zeile.trim().split(sep);
|
||||
for(int row = 0; row < adjacent.length; row++) {
|
||||
for(int col = 0; col < adjacent.length; col++) {
|
||||
adjacent2[row][col] = 0; // Initialize Array
|
||||
for(int pos = 0; pos < adjacent.length; pos++) { // Position in Array
|
||||
adjacent2[row][col] += adjacent[row][pos] * adjacent[pos][col]; // row * col
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new GraphException("Datei-Fehler bei receiveValues(): " + e.getMessage());
|
||||
} catch (IOException e) {
|
||||
throw new GraphException("Datei-Fehler bei receiveValues(): " + e.getMessage());
|
||||
return adjacent2;
|
||||
}
|
||||
return false;
|
||||
|
||||
public static void getAdjacent2() {
|
||||
int[][] adjacent2 = calculateAdjacent2(adjacent);
|
||||
|
||||
System.out.println("A²(G):");
|
||||
if (adjacent.length > 0)
|
||||
{
|
||||
for (int i = 0; i < adjacent.length; i++) {
|
||||
for (int j = 0; j < adjacent.length; j++) {
|
||||
System.out.print(adjacent2[i][j] + ", ");
|
||||
}
|
||||
System.out.println("\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("Empty Array");
|
||||
}
|
||||
}
|
||||
|
||||
public static int[][] calculateAdjacent3(int[][] adjacent, int[][] adjacent2) {
|
||||
|
||||
int[][] adjacent3 = new int[adjacent.length][adjacent.length];
|
||||
|
||||
for(int row = 0; row < adjacent.length; row++) {
|
||||
for(int col = 0; col < adjacent.length; col++) {
|
||||
for(int pos = 0; pos < adjacent.length; pos++) {
|
||||
adjacent3[row][col] += adjacent2[pos][col] * adjacent[row][pos];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return adjacent3;
|
||||
}
|
||||
|
||||
public static void getAdjacent3() {
|
||||
int[][] adjacent3 = calculateAdjacent3(adjacent, calculateAdjacent2(adjacent));
|
||||
|
||||
System.out.println("A³(G):");
|
||||
if (adjacent.length > 0)
|
||||
{
|
||||
for (int i = 0; i < adjacent.length; i++) {
|
||||
for (int j = 0; j < adjacent.length; j++) {
|
||||
System.out.print(adjacent3[i][j] + ", ");
|
||||
}
|
||||
System.out.println("\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("Empty Array");
|
||||
}
|
||||
}
|
||||
|
||||
// public boolean receiveValues() throws GraphException {
|
||||
// try (BufferedReader br = new BufferedReader(new FileReader(""))) { // filePath von application.RootBorderPane.importCSV()
|
||||
// String zeile;
|
||||
// String[] zeilenTeile;
|
||||
// String sep = ";"; // erwartetes Trennzeichen in der csv-Datei
|
||||
// int rowLength = 0;
|
||||
//
|
||||
//
|
||||
// zeile = br.readLine(); // wenn keine Zeile gefunden, dann return null
|
||||
//
|
||||
// while(zeile != null) {
|
||||
// rowLength++;
|
||||
// }
|
||||
//
|
||||
// } catch (FileNotFoundException e) {
|
||||
// throw new GraphException("Datei-Fehler bei receiveValues(): " + e.getMessage());
|
||||
// } catch (IOException e) {
|
||||
// throw new GraphException("Datei-Fehler bei receiveValues(): " + e.getMessage());
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
12
src/test/GraphTest.java
Normal file
12
src/test/GraphTest.java
Normal file
@ -0,0 +1,12 @@
|
||||
package test;
|
||||
|
||||
import model.Graph;
|
||||
|
||||
public class GraphTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
Graph.getAdjacent3();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user