1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* IC 312 HW 10: Shortest path to Google
 * YOUR NAME HERE
 */
 
import java.util.*;
 
/** A graph of ping delays throughout a network.
 * Each node label is a domain name such as www.usna.edu,
 * and each edge weight is the latency in that transmission,
 * as a floating-point value for the number of milliseconds.
 */
public class PingGraph {
  
  // TODO: Your data structure to store the edges should be a
  // field of the class defined here.
  // I recommend a Map from Strings to Vertex objects, where
  // each Vertex contains a list of outgoing edges.
  // (You will need to create the Vertex class yourself!)
 
  /** Constructor for a new, empty graph. */
  public PingGraph() {
    // TODO initialize your fields
  }
 
  /** Adds a new edge, and possibly new vertices, to the graph. */
  public void addEdge(PingEdge ee) {
    // TODO check if the edge's vertices are in the data structure.
    // If not, you might have to add one or both vertices.
    // Then of course you have to add that edge to the appropriate
    // list in your adjacency list.
  }
 
  /** Gets all edges that have the given source. */
  public List<PingEdge> neighbors(String source) {
    // TODO look up the source vertex and return a list of outgoing edges.
    return null; // (This is just here to stop compiler errors. Remove it!)
  }
}