diff options
author | Jonas Smedegaard <dr@jones.dk> | 2025-04-29 07:19:10 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2025-04-29 07:19:10 +0200 |
commit | 705b7a5a32793f7ed8a24b8b35afe3f9d49348be (patch) | |
tree | 7cffeb0de03a4638b87f04e01e7193eacbeaeede /src/com.example.portfolio3/com/example/portfolio3/EdgeGraph.java | |
parent | a5c3599d7bc7a9ef5583ad2d50a55975f030fbea (diff) |
tidy whitespace
Diffstat (limited to 'src/com.example.portfolio3/com/example/portfolio3/EdgeGraph.java')
-rw-r--r-- | src/com.example.portfolio3/com/example/portfolio3/EdgeGraph.java | 66 |
1 files changed, 37 insertions, 29 deletions
diff --git a/src/com.example.portfolio3/com/example/portfolio3/EdgeGraph.java b/src/com.example.portfolio3/com/example/portfolio3/EdgeGraph.java index 979b118..8bd9259 100644 --- a/src/com.example.portfolio3/com/example/portfolio3/EdgeGraph.java +++ b/src/com.example.portfolio3/com/example/portfolio3/EdgeGraph.java @@ -10,33 +10,41 @@ import java.util.Set; /// EdgeGraph - One big set of all edges in the graph class EdgeGraph extends AbstractGraph { - /// foo - EdgeGraph() {} - - /// foo - Set<Edge> edges=new HashSet<>(); - - /// foo - public void insertEdge(final Vertex v1, final Vertex v2, final int w){ - edges.add(new Edge(v1,v2,w)); - } - - /// foo - public Collection<Edge> edges(){return edges;} - - /// foo - public Collection<Edge> outEdge(final Vertex v){ - ArrayList<Edge> outEdge=new ArrayList<>(); - for(Edge e:edges)if(e.from()==v)outEdge.add(e); - return outEdge; - } - - /// foo - public Integer getWeight(final Vertex v1, final Vertex v2){ - // linear in number of edges in the graph - for(Edge e:edges){ - if(e.from()==v1 && e.to()==v2)return e.weight(); - } - return null; - } + /// foo + EdgeGraph() { } + + /// foo + Set<Edge> edges = new HashSet<>(); + + /// foo + public void insertEdge(final Vertex v1, final Vertex v2, final int w) { + edges.add(new Edge(v1, v2, w)); + } + + /// foo + public Collection<Edge> edges() { + return edges; + } + + /// foo + public Collection<Edge> outEdge(final Vertex v) { + ArrayList<Edge> outEdge = new ArrayList<>(); + for (Edge e: edges) + if (e.from() == v) + outEdge.add(e); + + return outEdge; + } + + /// foo + public Integer getWeight(final Vertex v1, final Vertex v2) { + + // linear in number of edges in the graph + for (Edge e:edges) { + if (e.from() == v1 && e.to() == v2) + return e.weight(); + } + + return null; + } } |