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

Type Parameters:
V - The vertices in the graph.
All Superinterfaces:
java.lang.Cloneable
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 edge.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 edge.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.1 2011/09/29 12:43:04 dogu3912 Exp $
Author:
johannes.kiesel(/\t)uni-weimar.de
See Also:
UndirectedGraph

Method Summary
 UndirectedGraph.Edge<V> clone()
          Clones this edge.
 boolean exists()
          Checks if this edge exists in the graph.
 V getVertexA()
          Returns one vertex of this edge.
 V getVertexB()
          Returns the other vertex of this edge (not the one returned be getVertexA()).
 double getWeight()
          Returns the weight of this edge.
 boolean isConnectedTo(V vertex)
          Checks if this edge is directly connected to a vertex.
 double remove()
          Removes this edge.
 double setWeight(double weight)
           Sets the weight of this edge.
 

Method Detail

getVertexA

V getVertexA()
Returns one vertex of this edge.

Returns:
one of the vertices of this edge.
See Also:
getVertexB()

getVertexB

V getVertexB()
Returns the other vertex of this edge (not the one returned be getVertexA()).

Returns:
the other vertex of this edge.
See Also:
getVertexA()

isConnectedTo

boolean isConnectedTo(V vertex)
                      throws java.lang.NullPointerException
Checks 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 vertex is null.
See Also:
getVertexA(), getVertexB()

exists

boolean exists()
               throws java.util.NoSuchElementException
Checks 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.
See Also:
UndirectedGraph.containsEdge(Object, Object)

setWeight

double setWeight(double weight)
                 throws java.util.NoSuchElementException

Sets the weight of this edge. This should always be the same as calling undirectedGraph.setEdgeWeight(Object, Object, double) using the two vertices of this edge as parameter.

Setting the weight to the value returned by undirectedGraph.getUnconnectedWeight() should be the same as calling edge.remove().

Parameters:
weight - the new weight of the edge.
Returns:
the old weight or the value returned by undirectedMutableGraph.getUnconnectedWeight() if the edge had not existed.
Throws:
java.util.NoSuchElementException - if at least one of the two vertices is not a part of the graph any more.
See Also:
exists(), remove(), UndirectedGraph.getUnconnectedWeight(), UndirectedGraph.setEdgeWeight(Object, Object, double)

remove

double remove()
              throws java.util.NoSuchElementException
Removes this edge. This should always be the same as calling undirectedMutableGraph.removeEdge(Object, Object) using the two vertices of this edge as parameter.

Returns:
the old weight or the value returned by undirectedMutableGraph.getUnconnectedWeight() if the edge had not existed.
Throws:
java.util.NoSuchElementException - If at least one of the two vertices is not a part of the graph any more.
See Also:
exists(), setWeight(double), UndirectedGraph.getUnconnectedWeight(), UndirectedGraph.setEdgeWeight(Object, Object, double)

getWeight

double getWeight()
                 throws java.util.NoSuchElementException
Returns 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 the same as undirectedGraph.getUnconnectedWeight() if this edge does not exist.
Throws:
java.util.NoSuchElementException - If at least one of the vertices was removed from the graph.
See Also:
exists(), UndirectedGraph.getUnconnectedWeight(), UndirectedGraph.getEdgeWeight(Object, Object)

clone

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

Returns:
A copy of this edge.