Question: Use the constructors in Table 10.1 TABLE 10.1The Edge Class Data Field Attribute private int dest The destination vertex for an edge private int source

Use the constructors in Table 10.1

TABLE 10.1The Edge Class

Data Field Attribute
private int dest The destination vertex for an edge
private int source The source vertex for an edge
private double weight The weight
Constructor Purpose
public Edge(int source, int dest) Constructs an Edge from source to dest. Sets the weight to 1.0
public Edge(int source, int dest, double w) Constructs an Edge from source to dest. Sets the weight to w
Method Behavior
public boolean equals(Object o) Compares two edges for equality. Edges are equal if their source and destination vertices are the same. The weight is not considered
public int getDest() Returns the destination vertex
public int getSource() Returns the source vertex
public double getWeight() Returns the weight
public int hashCode() Returns the hash code for an edge. The hash code depends only on the source and destination
public String toString() Returns a string representation of the edge

to create the Edge objects connecting vertices 9 through 12 for the graph in Figure 10.8.

FIGURE 10.8 Example of an Unconnected Graph

Use the constructors in Table 10.1 TABLE 10.1The Edge Class Data Field

Document the breadth-first search trees

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!