/GraphIO

Graphentheorie POS HTL Spengergasse

Primary LanguageJavaMIT LicenseMIT

Welcome to GraphIO 👋

License: MIT

GraphIO is a program developed in Java 17 for the calculation and representation of subareas of graph theory. It was developed as part of a programming assignment in the subject POS (graph theory).

GraphIO ist ein in Java 17 entwickeltes Programm zur Berechnung und Darstellung von Teilbereichen der Graphentheorie. Es wurde im Rahmen einer Programmieraufgabe im Fach POS (Graphentheorie) entwickelt.

Current features

Examples

Importing matrices from CSV files as adjacency matrix

class Test {
    public static void main(String[] args) {
        AdjacencyMatrix adjacencyMatrix = new AdjacencyMatrix("PATH-TO-YOUR-CSV-FILE");
    }
}

Calculating distance matrices

class Test {
    public static void main(String[] args) {
        AdjacencyMatrix adjacencyMatrix = new AdjacencyMatrix("PATH-TO-YOUR-CSV-FILE");
        DistanceMatrix distanceMatrix = new DistanceMatrix(adjacencyMatrix);
        
        distanceMatrix.printMatrix();
    }
}

Output

0|1|2|2|3|4|4|4|4|5|5|5|6|6|7|7|6|8|8|7|7|8|9|9|
1|0|1|1|2|3|3|3|3|4|4|4|5|5|6|6|5|7|7|6|6|7|8|8|
2|1|0|1|1|2|2|2|2|3|3|3|4|4|5|5|4|6|6|5|5|6|7|7|
2|1|1|0|1|2|2|2|2|3|3|3|4|4|5|5|4|6|6|5|5|6|7|7|
3|2|1|1|0|1|1|1|1|2|2|2|3|3|4|4|3|5|5|4|4|5|6|6|
4|3|2|2|1|0|1|2|2|3|3|2|3|4|5|5|4|6|6|5|5|6|7|7|
4|3|2|2|1|1|0|2|2|3|3|1|2|4|5|5|4|6|6|5|5|6|7|7|
4|3|2|2|1|2|2|0|1|1|1|3|4|2|3|3|2|4|4|3|3|4|5|5|
4|3|2|2|1|2|2|1|0|2|2|3|4|3|4|4|3|5|5|4|4|5|6|6|
5|4|3|3|2|3|3|1|2|0|1|4|5|2|3|3|2|4|4|3|3|4|5|5|
5|4|3|3|2|3|3|1|2|1|0|4|5|1|2|2|1|3|3|2|2|3|4|4|
5|4|3|3|2|2|1|3|3|4|4|0|1|5|6|6|5|7|7|6|6|7|8|8|
6|5|4|4|3|3|2|4|4|5|5|1|0|6|7|7|6|8|8|7|7|8|9|9|
6|5|4|4|3|4|4|2|3|2|1|5|6|0|1|2|2|2|2|3|3|4|5|5|
7|6|5|5|4|5|5|3|4|3|2|6|7|1|0|1|2|1|1|3|3|4|5|5|
7|6|5|5|4|5|5|3|4|3|2|6|7|2|1|0|1|2|2|2|2|3|4|4|
6|5|4|4|3|4|4|2|3|2|1|5|6|2|2|1|0|3|3|1|1|2|3|3|
8|7|6|6|5|6|6|4|5|4|3|7|8|2|1|2|3|0|1|4|4|5|6|6|
8|7|6|6|5|6|6|4|5|4|3|7|8|2|1|2|3|1|0|4|4|5|6|6|
7|6|5|5|4|5|5|3|4|3|2|6|7|3|3|2|1|4|4|0|1|2|3|3|
7|6|5|5|4|5|5|3|4|3|2|6|7|3|3|2|1|4|4|1|0|1|2|2|
8|7|6|6|5|6|6|4|5|4|3|7|8|4|4|3|2|5|5|2|1|0|1|1|
9|8|7|7|6|7|7|5|6|5|4|8|9|5|5|4|3|6|6|3|2|1|0|1|
9|8|7|7|6|7|7|5|6|5|4|8|9|5|5|4|3|6|6|3|2|1|1|0|

Calculating eccentricities

class Test {
    public static void main(String[] args) {
        AdjacencyMatrix adjacencyMatrix = new AdjacencyMatrix("PATH-TO-YOUR-CSV-FILE");
        DistanceMatrix distanceMatrix = new DistanceMatrix(adjacencyMatrix);
        Eccentricity eccentricity = new Eccentricity(distanceMatrix);
        
        eccentricity.printEccentricity();
    }
}

Output

{A=9, B=8, C=7, D=7, E=6, F=7, G=7, H=5, I=6, J=5, K=5, L=8, M=9, N=6, O=7, P=7, Q=6, R=8, S=8, T=7, U=7, V=8, W=9, X=9}

Calculating radius

class Test {
    public static void main(String[] args) {
        AdjacencyMatrix adjacencyMatrix = new AdjacencyMatrix("PATH-TO-YOUR-CSV-FILE");
        DistanceMatrix distanceMatrix = new DistanceMatrix(adjacencyMatrix);
        Eccentricity eccentricity = new Eccentricity(distanceMatrix);

        eccentricity.printRadius();
    }
}

Output

rad(G) = 5

Calculating diameter

class Test {
    public static void main(String[] args) {
        AdjacencyMatrix adjacencyMatrix = new AdjacencyMatrix("PATH-TO-YOUR-CSV-FILE");
        DistanceMatrix distanceMatrix = new DistanceMatrix(adjacencyMatrix);
        Eccentricity eccentricity = new Eccentricity(distanceMatrix);

        eccentricity.printDiameter();
    }
}

Output

dm(G) = 9

Calculating center

class Test {
    public static void main(String[] args) {
        AdjacencyMatrix adjacencyMatrix = new AdjacencyMatrix("PATH-TO-YOUR-CSV-FILE");
        DistanceMatrix distanceMatrix = new DistanceMatrix(adjacencyMatrix);
        Eccentricity eccentricity = new Eccentricity(distanceMatrix);

        eccentricity.printCenter();
    }
}

Output

Z(G) = {H,J,K}

Calculating path matrices

class Test {
    public static void main(String[] args) {
        AdjacencyMatrix adjacencyMatrix = new AdjacencyMatrix("PATH-TO-YOUR-CSV-FILE");
        PathMatrix pathMatrix = new PathMatrix(adjacencyMatrix);
        
        pathMatrix.printMatrix();
    }
}

Output

1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|
1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|
1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|
1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|
1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|
1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|
1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|
1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|
1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|
1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|
1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|
1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|
1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|
1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|
1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|
1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|
1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|
1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|
1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|
1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|
1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|
1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|
1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|
1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|

Calculating components

class Test {
    public static void main(String[] args) {
        AdjacencyMatrix adjacencyMatrix = new AdjacencyMatrix("PATH-TO-YOUR-CSV-FILE");
        PathMatrix pathMatrix = new PathMatrix(adjacencyMatrix);
        Components components = new Components(pathMatrix);

        components.print();
    }
}

Output

c(G) = 1
K₁ = (K(1), {A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X})

Calculating articulations

class Test {
    public static void main(String[] args) {
        AdjacencyMatrix adjacencyMatrix = new AdjacencyMatrix("PATH-TO-YOUR-CSV-FILE");
        PathMatrix pathMatrix = new PathMatrix(adjacencyMatrix);
        Components components = new Components(pathMatrix);
        Articulation articulation = new Articulation(adjacencyMatrix, components.getComponents().size());

        articulation.print();
    }
}

Output

B E G H K L O Q U V 

Calculating bridges

class Test {
    public static void main(String[] args) {
        AdjacencyMatrix adjacencyMatrix = new AdjacencyMatrix("PATH-TO-YOUR-CSV-FILE");
        PathMatrix pathMatrix = new PathMatrix(adjacencyMatrix);
        Components components = new Components(pathMatrix);
        Bridges bridges = new Bridges(adjacencyMatrix, components.getComponents().size());

        bridges.print();
    }
}

Output

[A,B]
[B,A]
[G,L]
[L,G]
[L,M]
[M,L]
[U,V]
[V,U]

Author

👤 Jovan Stojimirovic

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2022 Jovan Stojimirovic.
This project is MIT licensed.