summaryrefslogtreecommitdiff
path: root/src/com.example.portfolio3/com/example/portfolio3/MatrixGraph.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com.example.portfolio3/com/example/portfolio3/MatrixGraph.java')
-rw-r--r--src/com.example.portfolio3/com/example/portfolio3/MatrixGraph.java14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/com.example.portfolio3/com/example/portfolio3/MatrixGraph.java b/src/com.example.portfolio3/com/example/portfolio3/MatrixGraph.java
index 5a1f327..67c095e 100644
--- a/src/com.example.portfolio3/com/example/portfolio3/MatrixGraph.java
+++ b/src/com.example.portfolio3/com/example/portfolio3/MatrixGraph.java
@@ -37,11 +37,13 @@ public class MatrixGraph extends AbstractGraph {
/// @param v vertex
/// @return int
private int getIndex(final Vertex v) {
- if (vertex2index.containsKey(v))
+ if (vertex2index.containsKey(v)) {
return vertex2index.get(v);
+ }
int index = vertex2index.size();
- if (index >= index2vertex.length)
+ if (index >= index2vertex.length) {
throw new RuntimeException("Too many vertices in graph");
+ }
vertex2index.put(v, index);
index2vertex[index] = v;
@@ -59,7 +61,9 @@ public class MatrixGraph extends AbstractGraph {
for (int i = 0; i < numVertex; i++) {
for (int j = 0; j < numVertex; j++) {
Integer weight = matrix[i][j]; // may be null
- if (weight == null) continue;
+ if (weight == null) {
+ continue;
+ }
edges.add(new Edge(index2vertex[i],index2vertex[j],weight));
}
}
@@ -73,7 +77,9 @@ public class MatrixGraph extends AbstractGraph {
int i = vertex2index.get(v1);
for (int j = 0; j < numVertex; j++) {
Integer weight = matrix[i][j]; // may be null
- if (weight == null) continue;
+ if (weight == null) {
+ continue;
+ }
edges.add(new Edge(v1,index2vertex[j],weight));
}