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

All Superinterfaces:
java.lang.Cloneable
All Known Subinterfaces:
UndirectedMutableLongGraph.Edge
Enclosing interface:
UndirectedLongGraph

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

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

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

Method Detail

getVertexA

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

getVertexB

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

isConnectedTo

boolean isConnectedTo(long 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 UndirectedLongGraph.containsEdge(long, long) 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:
UndirectedLongGraph.containsEdge(long, long)

getWeight

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

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

UndirectedLongGraph.Edge clone()
Clone this edge.

Returns:
A copy of this edge.