I need help debugging my program: package graph; import java.util.ArrayDeque; import…
- User
I need help debugging my program: package graph;
import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; import java.util.Deque; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.Map; import java.util.PriorityQueue; import java.util.Queue; import java.util.Set;
/**
-
be used for any purpose. The graph is viewed as a collection
-
of vertices, which are sometimes connected by weighted, directed
-
edges.
-
Depth-First-Search, Breadth-First-Search, and Djikatra's.
-
"GraphAlgorithmObservers", which will be notified during the
-
performance of the graph algorithms to update the observers
-
on how the algorithms are progressing. */ public class WeightedGraph {
/* STUDENTS: You decide what data structure(s) to use to
- implement this class.
- You may use any data structures you like, and any Java
- collections that we learned about this semester. (You may
- not use any Java classes that were not covered during
- CMSC 132). Remember that you are implementing a weighted,
- directed graph. */ private Map<V, Map<V, Integer>> graph;
/* Collection of observers. Be sure to initialize this list
- in the constructor. The method "addObserver" will be
- called to populate this collection. Your graph algorithms
- (DFS, BFS, and Dijkstra) will notify these observers to let
- them know how the algorithms are progressing. */ private Collection<GraphAlgorithmObserver> observerList;
/** Initialize the data structures to "empty", including
- the collection of GraphAlgorithmObservers (observerList). */ public WeightedGraph() { graph = new HashMap<>(); observerList = new ArrayList<>(); }
/** Add a GraphAlgorithmObserver to the collection maintained
- by this graph (observerList).
- @param observer */ public void addObserver(GraphAlgorithmObserver observer) { observerList.add(observer); }
/** Add a vertex to the graph. If the vertex is already in the
- graph, throw an IllegalArgumentException.
- @param vertex vertex to be added to the graph
- Assistant
- User
Could you fix these issues for me?
- Assistant