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/AbstractGraph.java | |
parent | a5c3599d7bc7a9ef5583ad2d50a55975f030fbea (diff) |
tidy whitespace
Diffstat (limited to 'src/com.example.portfolio3/com/example/portfolio3/AbstractGraph.java')
-rw-r--r-- | src/com.example.portfolio3/com/example/portfolio3/AbstractGraph.java | 92 |
1 files changed, 48 insertions, 44 deletions
diff --git a/src/com.example.portfolio3/com/example/portfolio3/AbstractGraph.java b/src/com.example.portfolio3/com/example/portfolio3/AbstractGraph.java index 95c1030..793260a 100644 --- a/src/com.example.portfolio3/com/example/portfolio3/AbstractGraph.java +++ b/src/com.example.portfolio3/com/example/portfolio3/AbstractGraph.java @@ -7,48 +7,52 @@ import java.util.HashMap; import java.util.HashSet; /// foo -public abstract class AbstractGraph implements Graph{ - - /// foo - AbstractGraph() {} - - /// foo - private HashMap<String,Vertex> vertexMap=new HashMap<>(); - - /// foo - private HashSet<Vertex> vertexSet=new HashSet<>(); - - /// foo - /// @param s foo - /// @return Vertex - public Vertex vertex(final String s){ - if(vertexMap.containsKey(s))return vertexMap.get(s); - Vertex v=new Vertex(s); - vertexMap.put(s,v); - vertexSet.add(v); - return v; - } - - /// foo - public void insertEdge(final String v, final String u, final int w){ - insertEdge(vertex(v),vertex(u),w); - } - - /// foo - public Collection<Vertex> vertices() { return vertexSet; } - - /// foo - /// @param v1 foo - /// @param v2 foo - /// @param w foo - abstract public void insertEdge(Vertex v1, Vertex v2, int w); - - /// foo - abstract public Collection<Edge> edges(); - - /// foo - abstract public Collection<Edge> outEdge(Vertex v); - - /// foo - abstract public Integer getWeight(Vertex v1, Vertex v2); +public abstract class AbstractGraph implements Graph { + + /// foo + AbstractGraph() { } + + /// foo + private HashMap<String,Vertex> vertexMap = new HashMap<>(); + + /// foo + private HashSet<Vertex> vertexSet = new HashSet<>(); + + /// foo + /// @param s foo + /// @return Vertex + public Vertex vertex(final String s) { + if (vertexMap.containsKey(s)) + return vertexMap.get(s); + Vertex v = new Vertex(s); + vertexMap.put(s, v); + vertexSet.add(v); + + return v; + } + + /// foo + public void insertEdge(final String v, final String u, final int w) { + insertEdge(vertex(v), vertex(u), w); + } + + /// foo + public Collection<Vertex> vertices() { + return vertexSet; + } + + /// foo + /// @param v1 foo + /// @param v2 foo + /// @param w foo + abstract public void insertEdge(Vertex v1, Vertex v2, int w); + + /// foo + abstract public Collection<Edge> edges(); + + /// foo + abstract public Collection<Edge> outEdge(Vertex v); + + /// foo + abstract public Integer getWeight(Vertex v1, Vertex v2); } |