be.ac.ulg.montefiore.run.totem.topgen.util
Class RoutingMatrix

java.lang.Object
  extended by be.ac.ulg.montefiore.run.totem.topgen.util.RoutingMatrix
Direct Known Subclasses:
BooleanRoutingMatrix, RealRoutingMatrix

public abstract class RoutingMatrix
extends java.lang.Object

This is the base class for the routing matrix classes.

The matrix is a float matrix, so you can route packets from A to B with two different paths. As a routing matrix is generally a large sparse matrix, we represent it by means of a doubly linked structure.

The rows of the matrix designate the links of the topology and the columns designate the pairs of nodes of the topology.

Creation date: 2004

Author:
Jean Lepropre (lepropre@run.montefiore.ulg.ac.be)

Constructor Summary
RoutingMatrix()
           
 
Method Summary
protected  void add(float value, int link, int src, int dst)
          Like set but adds value to the current contained value.
 IntFloatPair[] getColumn(int src, int dst)
          Returns the non-null elements of the column corresponding to (src,dst).
 float getElement(int link, int src, int dst)
          Returns the value for the pair (src,dst) and the link link.
 IntPair getIds(int column)
          Returns the ids of the pair of nodes corresponding to the column column.
 int getKey(int src, int dst)
          Returns the column corresponding to the pair (src,dst).
 int getNbColumns()
          Returns the number of columns of this routing matrix.
 int getNbRows()
          Returns the number of rows of this routing matrix.
 IntFloatPair[] getRow(int link)
          Returns the non-null elements of the row corresponding to link.
abstract  void recompute()
          Recomputes the routing matrix.
protected  void set(float value, int link, int src, int dst)
          This method sets the element corresponding to link, src and dst to value.
protected  void setSize(int nbRows, int nbCols)
          Sets the size of the matrix.
 java.lang.String toString()
          Returns a string representing the matrix.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RoutingMatrix

public RoutingMatrix()
Method Detail

getKey

public final int getKey(int src,
                        int dst)
Returns the column corresponding to the pair (src,dst).

Throws:
java.lang.IllegalArgumentException - If src is equal to dst.

getIds

public final IntPair getIds(int column)
Returns the ids of the pair of nodes corresponding to the column column. The first int is the source node id and the second int is the destination node id.

Throws:
java.lang.IllegalArgumentException - If column has a bad value.

recompute

public abstract void recompute()
                        throws RoutingException,
                               NoRouteToHostException
Recomputes the routing matrix.

Throws:
RoutingException
NoRouteToHostException

getElement

public final float getElement(int link,
                              int src,
                              int dst)
Returns the value for the pair (src,dst) and the link link.

Throws:
java.lang.IllegalArgumentException - If link, src and/or dst have a bad value.

getRow

public final IntFloatPair[] getRow(int link)
Returns the non-null elements of the row corresponding to link. If there is no non-null element in the row link, it returns null. The int values of the IntFloatPair objects designate the indexes of the non-null elements and the float values of the IntFloatPair objects designate the values of the elements.

Throws:
java.lang.IllegalArgumentException - If link has a bad value.

getColumn

public final IntFloatPair[] getColumn(int src,
                                      int dst)
Returns the non-null elements of the column corresponding to (src,dst). If there is no non-null element, it returns null. The int values of the IntFloatPair objects designate the indexes of the non-null elements and the float values of the IntFloatPair objects designate the values of the elements.

Throws:
java.lang.IllegalArgumentException - If src and/or dst have a bad value.

getNbRows

public final int getNbRows()
Returns the number of rows of this routing matrix.


getNbColumns

public final int getNbColumns()
Returns the number of columns of this routing matrix.


add

protected final void add(float value,
                         int link,
                         int src,
                         int dst)
Like set but adds value to the current contained value.


set

protected final void set(float value,
                         int link,
                         int src,
                         int dst)
This method sets the element corresponding to link, src and dst to value. The subclasses should call this method to set the elements of the matrix.

Throws:
java.lang.IllegalArgumentException - If link, src and/or dst have a bad value.

setSize

protected final void setSize(int nbRows,
                             int nbCols)
Sets the size of the matrix. The subclasses should call this method to set the size of the matrix.


toString

public java.lang.String toString()
Returns a string representing the matrix.

Overrides:
toString in class java.lang.Object


Copyright © 2004-2007 Research Unit in Networking, All Rights Reserved.