fr.inria.opengve.bridge.interfaces
Interface Link<V>

All Known Subinterfaces:
Arc<E>, Edge<V>

public interface Link<V>

The root interface in the hierarchy of interfaces implemented by elements of the set returned by the linkSet method of some graph (more precisely, of an implementation of the Graph interface). As implied by its name, this interface models the mathematical link abstraction. In this sense, the definition of Link includes two elements, both of type V, which in turn is supposed to be the type of the vertices of the graph. However, besides these two vertices, an implementation of this interface may include other parameters to characterize a Link. Packages generaly does not any direct implementations of this interface: it provides implementations of more specific subinterfaces like Edge and Arc. This interface is typically used to pass links around and manipulate them where maximum generality is desired.

A single Link may be shared by different Graph objects (this is the case, for example, when one of these graphs is a sub-graph of the other). Be extremely careful to modify a Link since such a modification affects all graphs containing this Link. Two Link objects are equal if the equals method returns true. A Link defined by two vertices u and v may be directed or undirected, depending on the specification of the Object.equals(Object) method. Note that it is generally necessary to override the hashCode method whenever the equals method is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes.

One way to obtain a reference to a Link is from the iterator of the link set of the graph. A Link returned by this iterator is not guaranteed to be "safe", which means that references to it may be maintained by its link set. Be extremely careful to modify a Link since the consequences of such a modification in the link set are unpredictable.

The simplest way to create a link is by means of the method addLink of the Graph interface. Indeed, this is the more convenient way to create a Link in most cases. However, an implementation of this interface may also provide a public constructor but this requirement is not mandatory.

This interface does not stipulate any particular order for the vertices placed in the array returned by the toArray methods. However, some subinterfaces can stipulate such orders, like Arc.

Author:
fabrice.peix@sophia.inria.fr

Method Summary
 boolean contains(V o)
          Answers whether the link contains the specified object as one of its vertices.
 V getOpposite(V o)
          Returns the opposite vertex of a specified object in this link.
 boolean isLoop()
          Answers whether the both vertex of this link are identical.
 boolean leadsTo(V o)
          Answers whether a specified object is the second vertex of this link (optional operation).
 boolean leavesFrom(V o)
          Answers whether a specified object is the first vertex of this link (optional operation).
 V[] toArray()
          Returns the two vertices of the link in a 2-element array where one vertex is placed in the first position (index 0) and the other vertex occupies the second position (index 1).
<T> T[]
toArray(T[] a)
          Returns an array containing the two vertex of the link; the runtime type of the returned array is that of the specified array.
 

Method Detail

getOpposite

V getOpposite(V o)
Returns the opposite vertex of a specified object in this link. If the specified object is not a member of this link, then null is returned.

Parameters:
o - the specified object.
Returns:
the opposite vertex of the specified object in this link.

isLoop

boolean isLoop()
Answers whether the both vertex of this link are identical.

Returns:
true if this link is reflexive, and false otherwise.

leadsTo

boolean leadsTo(V o)
Answers whether a specified object is the second vertex of this link (optional operation).

Parameters:
o - the specified object.
Returns:
true if the specified object is the second vertex of this link, and false otherwise

leavesFrom

boolean leavesFrom(V o)
Answers whether a specified object is the first vertex of this link (optional operation).

Parameters:
o - the specified object.
Returns:
true if the specified object is the first vertex of this link, and false otherwise

contains

boolean contains(V o)
Answers whether the link contains the specified object as one of its vertices.

Parameters:
o - the specified object.
Returns:
true if the specified object belong to this link, and false otherwise

toArray

V[] toArray()
Returns the two vertices of the link in a 2-element array where one vertex is placed in the first position (index 0) and the other vertex occupies the second position (index 1). The vertexs appear in the returned array in the same order as they were added, i.e. the first vertex at position 0 and the second vertex at position 1. The Link is independant of the returned array, so changes to the array are not reflected in the link, and vice-versa.

Returns:
a 2-element array with the vertexs of this link.

toArray

<T> T[] toArray(T[] a)
Returns an array containing the two vertex of the link; the runtime type of the returned array is that of the specified array. The vertex appear in the returned array in the same order as they were added.

Parameters:
a - the array into which the vertex of this link are to be stored, if its length is at least 2; otherwise, a new array of the same runtime type is allocated for this purpose.
Returns:
an array containing the vertex of this link.
Throws:
java.lang.ArrayStoreException - the runtime type of a is not a supertype of the runtime type of every vertex of this edge.
java.lang.NullPointerException - if the specified array is null.


Copyright © 2009 INRIA (Projet Mascotte). All Rights Reserved.