Created
April 1, 2013 05:57
-
-
Save gtke/5283448 to your computer and use it in GitHub Desktop.
Vertex class for a graph
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Vertex { | |
| private int id; | |
| /** | |
| * A simple vertex class | |
| * | |
| * @param id | |
| */ | |
| public Vertex(int id) { | |
| this.id = id; | |
| } | |
| @Override | |
| public boolean equals(Object o) { | |
| if (o != null && o instanceof Vertex) { | |
| return id == ((Vertex) o).id; | |
| } else { | |
| return false; | |
| } | |
| } | |
| @Override | |
| public int hashCode() { | |
| return id; | |
| } | |
| public int getId() { | |
| return id; | |
| } | |
| public String toString(){ | |
| return ""+id; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment