de.aitools.aq.graph.weighted
Interface UndirectedIntGraph.Edge

All Superinterfaces:
java.lang.Cloneable
All Known Subinterfaces:
UndirectedMutableIntGraph.Edge
Enclosing interface:
UndirectedIntGraph

public static interface UndirectedIntGraph.Edge
extends java.lang.Cloneable

A possible edge connecting two vertices of an underlying UndirectedIntGraph. The edge denoted by this object must not necessarily exist in the graph -- use exists() to check.
This is a convenience object mainly used for iterators, which can return it as a tuple of two vertices. To avoid creating a huge amount of objects, implementors are encouraged to let iterators always return the same edge on a call to Iterator.next() but with updated vertices. Note that this means that a user has to use clone() if he wants an edge independent of the iterator.
The methods should simply call the appropriate methods of the underlying graph.

Version:
$Id: UndirectedIntGraph.java,v 1.2 2011/09/29 12:43:03 dogu3912 Exp $
Author:
johannes.kiesel(/\t)uni-weimar.de

Method Summary
 UndirectedIntGraph.Edge clone()
          Clone this edge.
 boolean exists()
          Check if this edge exists in the graph.
 int getVertexA()
           
 int getVertexB()
           
 double getWeight()
          Get the weight of this edge.
 boolean isConnectedTo(int vertex)
          Check if this edge is directly connected to a vertex.
 

Method Detail

getVertexA

int getVertexA()
Returns:
One of the vertices of this edge.
See Also:
getVertexB()

getVertexB

int getVertexB()
Returns:
The other vertex of this edge (see getVertexA()).

isConnectedTo

boolean isConnectedTo(int vertex)
Check if this edge is directly connected to a vertex.

Parameters:
vertex - The vertex.
Returns:
True if getVertexA() or getVertexB() would return given vertex.

exists

boolean exists()
Check if this edge exists in the graph. This should get the same result as calling UndirectedIntGraph.containsEdge(int, int) using the two vertices of this edge as parameters.

Returns:
If this edge exists.
Throws:
java.util.NoSuchElementException - If at least one of the vertices was removed from the graph. The graph must be mutable to do so (see UndirectedMutableGraph).
See Also:
UndirectedIntGraph.containsEdge(int, int)

getWeight

double getWeight()
Get the weight of this edge. This should be the same as calling UndirectedIntGraph.getEdgeWeight(int, int) using the two vertices of this edge as parameters.

Returns:
The weight or UndirectedIntGraph.getUnconnectedWeight() if this edge does not exist.
Throws:
java.util.NoSuchElementException - If at least one of the vertices was removed from the graph. The graph must be mutable to do so (see UndirectedMutableGraph).
See Also:
exists()

clone

UndirectedIntGraph.Edge clone()
Clone this edge.

Returns:
A copy of this edge.