Skip to content

Instantly share code, notes, and snippets.

@gtke
Created April 1, 2013 05:57
Show Gist options
  • Select an option

  • Save gtke/5283448 to your computer and use it in GitHub Desktop.

Select an option

Save gtke/5283448 to your computer and use it in GitHub Desktop.
Vertex class for a graph
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