ch.ethz.graphbench.toolbox
Class Edge

java.lang.Object
  |
  +--ch.ethz.graphbench.toolbox.Edge

public class Edge
extends java.lang.Object

Class representing an edge in 2D eucledian space.
A new edge cannot be instanciated directly, use the method createEdge(Vertex from, Vertex to) from the class Graph instead.


Field Summary
static int ACTIVE_STATE
          Specifies that the edge is currently active
static java.awt.Color DEFAULT_EDGE_COLOR
          The default color of an edge.
static int INVALID_STATE
          Specifies that the edge is invalid
static int PROCESSED_STATE
          Specifies that the edge has been processed
static int QUEUED_STATE
          Specifies that the edge is currently queued
static int VALID_STATE
          Specifies that the edge is valid
static int VOID_STATE
          Specifies that the edge is currently active
 
Method Summary
 boolean equals(java.lang.Object obj)
          Checks if the edge equals to a given object.
Two edges are considered equal if:
the graph is not directed and the edges connect the same two vertices the graph is directed and the start and end vertex of the edges are the same
 java.awt.Color getColor()
          Gets the color of the edge
 int getEdgeState()
          Gets the state of the edge
 Vertex getEndVertex()
          Gets the endVertex attribute of the Edge object
 int getIndex()
          Gets the index attribute of the edge
 double getLength()
          Gets the length of the edge in eucledian space
 Vertex getOppositeVertex(Vertex vertex)
          Returns the opposite vertex, for the given vertex.
 Vertex getStartVertex()
          Gets the startVertex attribute of the Edge object
 java.lang.Object getUserData(java.lang.Object key)
          Returns the value to which the specified key is mapped.
 int getWeight()
          Gets the weight of the edge.
 void putUserData(java.lang.Object key, java.lang.Object value)
          Maps the specified key to the specified value.
 void resetEdgeState()
          Resets the edge state.
 void setColor(java.awt.Color color)
          Sets the color of the edge
 void setEdgeState(int state)
          Sets the state of the edge.
Valid states are: QUEUED_STATE, ACTIVE_STATE and PROCESSED_STATE.
An edge can only be in one state at any given time.
 void setWeight(int weight)
          Sets the edge weight.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_EDGE_COLOR

public static final java.awt.Color DEFAULT_EDGE_COLOR
The default color of an edge.

VOID_STATE

public static final int VOID_STATE
Specifies that the edge is currently active

ACTIVE_STATE

public static final int ACTIVE_STATE
Specifies that the edge is currently active

QUEUED_STATE

public static final int QUEUED_STATE
Specifies that the edge is currently queued

PROCESSED_STATE

public static final int PROCESSED_STATE
Specifies that the edge has been processed

VALID_STATE

public static final int VALID_STATE
Specifies that the edge is valid

INVALID_STATE

public static final int INVALID_STATE
Specifies that the edge is invalid
Method Detail

setColor

public void setColor(java.awt.Color color)
Sets the color of the edge
Parameters:
color - The new color value

setEdgeState

public void setEdgeState(int state)
Sets the state of the edge.
Valid states are: QUEUED_STATE, ACTIVE_STATE and PROCESSED_STATE.
An edge can only be in one state at any given time.
Parameters:
state - The new state of the edge

resetEdgeState

public void resetEdgeState()
Resets the edge state.

getIndex

public int getIndex()
Gets the index attribute of the edge
Returns:
The index value

getLength

public double getLength()
Gets the length of the edge in eucledian space
Returns:
The length value

getWeight

public int getWeight()
Gets the weight of the edge.
Returns:
The edge weight or 0 if no weight has been set.

setWeight

public void setWeight(int weight)
Sets the edge weight.
Parameters:
weight - New weight of the edge, 0 for unweighted edges.

getUserData

public java.lang.Object getUserData(java.lang.Object key)
Returns the value to which the specified key is mapped.
Parameters:
key - key identifying value to be returned
Returns:
the value to which the key is mapped; null if the key is not mapped to any value

getColor

public java.awt.Color getColor()
Gets the color of the edge
Returns:
The color value

getEdgeState

public int getEdgeState()
Gets the state of the edge
Returns:
The state of the edge (QUEUED_STATE, ACTIVE_STATE or PROCESSED_STATE) or -1 if state has not been set.

getOppositeVertex

public Vertex getOppositeVertex(Vertex vertex)
Returns the opposite vertex, for the given vertex.
Parameters:
vertex - Vertex to find opposite of.
Returns:
Opposite vertex.

getStartVertex

public Vertex getStartVertex()
Gets the startVertex attribute of the Edge object
Returns:
The startVertex value

getEndVertex

public Vertex getEndVertex()
Gets the endVertex attribute of the Edge object
Returns:
The endVertex value

putUserData

public void putUserData(java.lang.Object key,
                        java.lang.Object value)
Maps the specified key to the specified value. Neither the key nor the value can be null.
The value can be retrieved by calling the get method with a key that is equal to the original key.
Parameters:
key - the key
value - the value

equals

public boolean equals(java.lang.Object obj)
Checks if the edge equals to a given object.
Two edges are considered equal if:
Overrides:
equals in class java.lang.Object
Parameters:
obj - Object to compare to.
Returns:
true if object is equal, false otherwise