diff options
author | Jonas Smedegaard <dr@jones.dk> | 2025-04-26 19:32:53 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2025-04-26 19:32:53 +0200 |
commit | e4a0762c7a2ac3afb8e33bf24fd7495553b5819f (patch) | |
tree | 83d738e242670a4171cd20727f697744d05eaec8 /com/example/portfolio3/AdjMapGraph.java | |
parent | 7f93e18b6424b292d4f54fb746aeb6e10b62e76d (diff) |
use Maven idiomatic root path src/main/java
Diffstat (limited to 'com/example/portfolio3/AdjMapGraph.java')
-rw-r--r-- | com/example/portfolio3/AdjMapGraph.java | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/com/example/portfolio3/AdjMapGraph.java b/com/example/portfolio3/AdjMapGraph.java deleted file mode 100644 index 85e5d04..0000000 --- a/com/example/portfolio3/AdjMapGraph.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.example.portfolio3; - -// origin: <https://moodle.ruc.dk/course/section.php?id=211877> - -import java.util.*; - -/// Adjecency Map Graph - A map from vertices to map of target vertex to edge -class AdjMapGraph extends AbstractGraph { - - /// foo - AdjMapGraph() {} - - /// foo - private Map<Vertex, Map<Vertex, Edge>> outEdge = new HashMap<>(); - - /// foo - public void insertEdge(Vertex v1, Vertex v2, int w) { - Edge e = new Edge(v1,v2, w); - if (!outEdge.containsKey(e.from())) - outEdge.put(e.from(), new HashMap<Vertex, Edge>()); - outEdge.get(e.from()).put(e.to(), e); - } - - /// foo - public Collection<Edge> edges() { - Set<Edge> edges = new HashSet<>(); - for (Vertex v : outEdge.keySet()) - for (Vertex w : outEdge.get(v).keySet()) - edges.add(outEdge.get(v).get(w)); - return edges; - } - - /// foo - public Collection<Edge> outEdge(Vertex v) { - return outEdge.get(v).values(); - } - - /// foo - public Integer getWeight(Vertex v1, Vertex v2) { - // constant time operation - if(!outEdge.containsKey(v1))return null; - if(!outEdge.get(v1).containsKey(v2))return null; - return outEdge.get(v1).get(v2).weight(); - } -} |