This repository acts as a personal archive for my solutions to EdX course *Data Structures and Software Design* from PennX.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

40 lines
745 B

public class Edge {
private final Node source;
private final Node destination;
public Edge(Node source, Node destination) {
this.source = source;
this.destination = destination;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Edge)) {
return false;
}
Edge otherEdge = (Edge) obj;
Node otherSource = otherEdge.getSource();
Node otherDest = otherEdge.getDestination();
return (otherSource.equals(source)
&& otherDest.equals(destination));
}
@Override
public int hashCode() {
return source.hashCode() + destination.hashCode();
}
public Node getSource() {
return source;
}
public Node getDestination() {
return destination;
}
}