Constructor and Description |
---|
Edge(int t,
int h)
Partial constructor (weight is set to 0)
|
Edge(int t,
int h,
int w)
Complete Edge constructor
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Edge otherEdge) |
Edge |
copy()
Returns a copy of this
|
boolean |
equals(java.lang.Object obj) |
int |
getHead()
The head of a directed edge (u,v) is v
In an undirected edge, head is one of the edge's endpoints
|
int |
getTail()
The tail of a directed edge (u,v) is u
In an undirected edge, tail is one of the edge's endpoints
|
int |
getWeight()
Returns the weight of the Edge
all object of the class always have a weight that by default is set to 0
|
int |
hashCode() |
Edge |
reverse()
Returns the reverse of this edge (tail and head swapped)
|
java.lang.String |
serialize()
Returns the Edge as a string (tail, head and weight in this order and separated by blank)
|
void |
setTail(int t)
Sets the value of the tail node
|
java.lang.String |
toString() |
public Edge(int t, int h, int w)
t
- tailh
- headw
- weight
Creates an edge with tail t, head h and weight w
Recall that if the edge is directed tail and head are as follows (tail,head)
if the edge is undirected, tail and head are the two endpointspublic Edge(int t, int h)
t
- tailh
- head
Creates an edge with tail t, head h and weight 0
Recall that if the edge is directed tail and head are as follows (tail,head)
if the edge is undirected, tail and head are the two endpointspublic int getHead()
public int getWeight()
public int getTail()
public void setTail(int t)
t
- tailpublic Edge copy()
public Edge reverse()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int compareTo(Edge otherEdge)
compareTo
in interface java.lang.Comparable<Edge>
public java.lang.String serialize()
public java.lang.String toString()
toString
in class java.lang.Object