Skip to content

Commit

Permalink
formatted code, removed unused methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Jajaho committed Aug 30, 2022
1 parent 2ee1987 commit 2d7d658
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 40 deletions.
33 changes: 0 additions & 33 deletions src/main/java/org/jajaho/data/CircuitGraph.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package org.jajaho.data;

import org.jgrapht.alg.cycle.CycleDetector;
import org.jgrapht.graph.Pseudograph;

import java.util.HashSet;
import java.util.Set;

public class CircuitGraph extends Pseudograph<Integer, Edge> {

public CircuitGraph(Class<? extends Edge> edgeClass) {
Expand Down Expand Up @@ -43,33 +39,4 @@ public Integer getOppositeOf(Integer vertex, Edge edge) {
return getEdgeTarget(edge);
return null;
}

public Set<Integer> getAcyclicVertices() {
CycleDetector cDetect = new CycleDetector(this);
Set<Integer> set = new HashSet<>();

for (Integer vertex : vertexSet()) {
if (!cDetect.detectCyclesContainingVertex(vertex)) {
set.add(vertex);
}
}
return set;
}

// AbstractBaseGraph uses private IntrusiveEdgesSpecifics to set/get EdgeWeight
public void setEdgeType(Edge e, Component type) {
if (e == null) {
throw new NullPointerException();
} else {
e.setComponentType(type);
}
}

public Component getEdgeType(Edge e) {
if (e == null) {
throw new NullPointerException();
} else {
return e.getComponentType();
}
}
}
2 changes: 2 additions & 0 deletions src/main/java/org/jajaho/data/Edge.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public class Edge extends DefaultEdge {
private BigDecimal value;
private Component componentType;

public Edge() {}

// TODO - Ensure correct format for longer vertices
public void printArt() {
System.out.println(" " + name);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jajaho/data/Sle.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public Sle(CircuitGraph graph) {
continue;
for (Edge edge : graph.edgesOf(vertex)) {

switch (graph.getEdgeType(edge)) {
switch (edge.getComponentType()) {
case I:
Integer targetV = graph.getEdgeTarget(edge);
Integer sourceV = graph.getEdgeTarget(edge);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jajaho/util/GraphUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static boolean validateGraph(CircuitGraph graph, Scanner sc) {
int i = 0;

// TODO - Check whether graph is empty
test[i++] = checkForSelfLoops(graph,sc);
test[i++] = checkForSelfLoops(graph, sc);
test[i++] = checkForFloatingVertices(graph, sc);
test[i++] = checkHasSource(graph);

Expand Down Expand Up @@ -124,7 +124,7 @@ private static boolean checkForSelfLoops(CircuitGraph graph, Scanner sc) {

private static boolean checkHasSource(CircuitGraph graph) {
for (Edge edge : graph.edgeSet()) {
if (graph.getEdgeType(edge).equals(Component.I) || graph.getEdgeType(edge).equals(Component.U))
if (edge.getComponentType().equals(Component.I) || edge.getComponentType().equals(Component.U))
System.out.println("Network has a valid source.");
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jajaho/util/MathUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static double determinant(double[][] a) {
case 2:
return a[0][0] * a[1][1] - a[1][0] * a[0][1];
case 3:
return a[0][0] * a[1][1] * a[2][2]
return a[0][0] * a[1][1] * a[2][2]
+ a[0][1] * a[1][2] * a[2][0]
+ a[0][2] * a[1][0] * a[2][1]
- a[2][0] * a[1][1] * a[0][2]
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/org/jajaho/util/ReadUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
import org.jajaho.data.CircuitGraph;
import org.jajaho.main.Main;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Scanner;

public class ReadUtil {
Expand Down

0 comments on commit 2d7d658

Please sign in to comment.