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

All Superinterfaces:
java.lang.Cloneable
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 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: UndirectedIntGraph.java,v 1.1 2011/09/29 12:43:04 dogu3912 Exp $
Author:
johannes.kiesel(/\t)uni-weimar.de

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

Method Detail

getVertexA

int getVertexA()
Returns one vertex of this edge.

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

getVertexB

int 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(int vertex)
Check if this edge is directly connected to a certain vertex.

Parameters:
vertex - the vertex.
Returns:
true if getVertexA() or getVertexB() would return given vertex.
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 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.
See Also:
UndirectedIntGraph.containsEdge(int, int)

setWeight

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

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

Setting the weight to the value returned by undirectedIntGraph.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(), UndirectedIntGraph.getUnconnectedWeight(), UndirectedIntGraph.setEdgeWeight(int, int, double)

remove

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

Returns:
the old weight or the value returned by undirectedIntGraph.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), UndirectedIntGraph.getUnconnectedWeight(), UndirectedIntGraph.setEdgeWeight(int, int, double)

getWeight

double getWeight()
                 throws java.util.NoSuchElementException
Returns 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 the value returned by undirectedIntGraph.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(), UndirectedIntGraph.getEdgeWeight(int, int), UndirectedIntGraph.getUnconnectedWeight()

clone

UndirectedIntGraph.Edge clone()
Clones this edge.

Returns:
A copy of this edge.