edu.uci.ics.jung.graph.decorators
Class EdgeWeightLabeller

java.lang.Object
  extended byedu.uci.ics.jung.graph.decorators.EdgeWeightLabeller

public class EdgeWeightLabeller
extends java.lang.Object

A EdgeWeightLabeller applies a label to the edges of a Graph. All edge weights are integers; weights need not be unique. (The cost of not being unique is that there's no way to look up edges by weight.) Note that this stores information with the graph, and as such is not flexible to addition and substraction of nodes.

Author:
danyelf TODO : Should store weight in a decorator, per-Edge instead of per-Graph.

Method Summary
 Graph getGraph()
          Returns the graph associated with this particular labeller.
static EdgeWeightLabeller getLabeller(Graph g)
          Finds or creates an edge labeleller for the graph, using the default user data key.
static EdgeWeightLabeller getLabeller(Graph g, java.lang.Object key)
          Finds or creates an edge labeleller for the graph, using the given userdata key.
 int getWeight(Edge e)
          Gets the weight of a particualr edge.
static boolean hasWeightLabeller(Graph g)
          Checks for an edge labeleller for the graph, using the default user data key.
static boolean hasWeightLabeller(Graph g, java.lang.Object key)
          Checks an edge labeleller for the graph at the given key.
 void setWeight(Edge e, int i)
          Sets an edge to this weight.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getLabeller

public static EdgeWeightLabeller getLabeller(Graph g)
Finds or creates an edge labeleller for the graph, using the default user data key.

Parameters:
g -
Returns:
the labeller

hasWeightLabeller

public static boolean hasWeightLabeller(Graph g)
Checks for an edge labeleller for the graph, using the default user data key.

Parameters:
g -
Returns:
the labeller

hasWeightLabeller

public static boolean hasWeightLabeller(Graph g,
                                        java.lang.Object key)
Checks an edge labeleller for the graph at the given key.

Returns:
the labeller

getLabeller

public static EdgeWeightLabeller getLabeller(Graph g,
                                             java.lang.Object key)
Finds or creates an edge labeleller for the graph, using the given userdata key.

Parameters:
g -
Returns:
the labeller

getWeight

public int getWeight(Edge e)
Gets the weight of a particualr edge. Throws an exception if the edge is not weighted, or if the edge is not a part of the graph.

Parameters:
e - an edge that has been weighted.

getGraph

public Graph getGraph()
Returns the graph associated with this particular labeller.


setWeight

public void setWeight(Edge e,
                      int i)
Sets an edge to this weight.

Parameters:
e - the edge
i - the weight
Throws:
if - the edge is not part of the graph