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}]]
|
@ -7,31 +7,128 @@ import java.io.IOException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class Graph {
|
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() {
|
public Graph() {
|
||||||
values = new ArrayList<Graph>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean receiveValues() throws GraphException {
|
public static int[][] calculateAdjacent2(int[][] adjacent) {
|
||||||
try (BufferedReader br = new BufferedReader(new FileReader(""))) { // filePath von application.RootBorderPane.importCSV()
|
|
||||||
String zeile;
|
int[][] adjacent2 = new int[adjacent.length][adjacent.length];
|
||||||
String[] zeilenTeile;
|
|
||||||
String sep = ";"; // erwartetes Trennzeichen in der csv-Datei
|
for(int row = 0; row < adjacent.length; row++) {
|
||||||
|
for(int col = 0; col < adjacent.length; col++) {
|
||||||
|
adjacent2[row][col] = 0; // Initialize Array
|
||||||
zeile = br.readLine(); // wenn keine Zeile gefunden, dann return null
|
for(int pos = 0; pos < adjacent.length; pos++) { // Position in Array
|
||||||
|
adjacent2[row][col] += adjacent[row][pos] * adjacent[pos][col]; // row * col
|
||||||
while (zeile != null) {
|
}
|
||||||
zeilenTeile = zeile.trim().split(sep);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (FileNotFoundException e) {
|
return adjacent2;
|
||||||
throw new GraphException("Datei-Fehler bei receiveValues(): " + e.getMessage());
|
}
|
||||||
} catch (IOException e) {
|
|
||||||
throw new GraphException("Datei-Fehler bei receiveValues(): " + e.getMessage());
|
public static void getAdjacent2() {
|
||||||
}
|
int[][] adjacent2 = calculateAdjacent2(adjacent);
|
||||||
return false;
|
|
||||||
}
|
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