diff options
author | Jonas Smedegaard <dr@jones.dk> | 2025-04-29 08:09:28 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2025-04-29 08:09:28 +0200 |
commit | 3738c1fc8b2fa92b819b1ff948b3b39de60757b7 (patch) | |
tree | c5db7a878770da6c8180cc468184712d585b0d88 /src/com.example.portfolio3/com/example/portfolio3/MatrixGraph.java | |
parent | 794be4694f1a1fa36d87543aab840331c6d39745 (diff) |
always use brace in for- and if-construct
Diffstat (limited to 'src/com.example.portfolio3/com/example/portfolio3/MatrixGraph.java')
-rw-r--r-- | src/com.example.portfolio3/com/example/portfolio3/MatrixGraph.java | 14 |
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)); } |