de.aitools.aq.graph.weighted
Interface UndirectedGraph.Edge<V>

Type Parameters:
V - The vertices in the graph.
All Superinterfaces:
java.lang.Cloneable
All Known Subinterfaces:
UndirectedMutableGraph.Edge<V>
Enclosing interface:
UndirectedGraph<V>

public static interface UndirectedGraph.Edge<V>
extends java.lang.Cloneable

A possible edge connecting two vertices of an underlying UndirectedGraph. 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: UndirectedGraph.java,v 1.2 2011/09/29 12:43:03 dogu3912 Exp $
Author:
johannes.kiesel(/\t)uni-weimar.de

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

Method Detail

getVertexA

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

getVertexB

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

isConnectedTo

boolean isConnectedTo(V 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.
Throws:
java.lang.NullPointerException - If the vertices is null.

exists

boolean exists()
Check if this edge exists in the graph. This should get the same result as calling UndirectedGraph.containsEdge(Object, Object) 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:
UndirectedGraph.containsEdge(Object, Object)

getWeight

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

Returns:
The weight or UndirectedGraph.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

UndirectedGraph.Edge<V> clone()
Clone this edge.

Returns:
A copy of this edge.