Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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

    java.lang.Object
      edu.uci.ics.jung.graph.decorators.EdgeWeightLabeller

All Implemented Interfaces:
  NumberEdgeValue

public class EdgeWeightLabeller
extends Object
implements NumberEdgeValue

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.

Field Summary
`static Object` | `WEIGHT_DEFAULT_KEY` The UserData key that stores edge weights.

Method Summary
`void` | `clear()` Clears all weights stored by this decorator.
`Graph` | `getGraph()` Returns the graph associated with this particular labeller.
`static EdgeWeightLabeller` | `getLabeller(Graph g)` Finds or creates an edge labeller for the graph, using the default user data key.
`static EdgeWeightLabeller` | `getLabeller(Graph g, Object key)` Finds or creates an edge labeleller for the graph, using the given userdata key.
`Number` | `getNumber(ArchetypeEdge e)`
`int` | `getWeight(ArchetypeEdge 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, Object key)` Checks an edge labeleller for the graph at the given key.
`Number` | `removeWeight(ArchetypeEdge e)` Removes the weight stored by this decorator for the indicated edge `e`, and returns the value of this weight (or `null` if there was no such weight for this edge).
`void` | `setNumber(ArchetypeEdge e, Number n)`
`void` | `setWeight(ArchetypeEdge e, int i)` Sets an edge to this weight.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### WEIGHT_DEFAULT_KEY

    public static final Object WEIGHT_DEFAULT_KEY

  The UserData key that stores edge weights.

Method Detail

### getLabeller

    public static EdgeWeightLabeller getLabeller(Graph g)

  Finds or creates an edge labeller 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,
                                            Object key)

  Checks an edge labeleller for the graph at the given key.

  Returns:
    the labeller

### getLabeller

    public static EdgeWeightLabeller getLabeller(Graph g,
                                                 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(ArchetypeEdge 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(ArchetypeEdge 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

### removeWeight

    public Number removeWeight(ArchetypeEdge e)

  Removes the weight stored by this decorator for the indicated edge `e`, and returns the value of this weight (or `null` if there was no such weight for this edge).

### clear

    public void clear()

  Clears all weights stored by this decorator.

### getNumber

    public Number getNumber(ArchetypeEdge e)

  Specified by:
    `getNumber` in interface `NumberEdgeValue`
  Parameters:
    `e` - the edge to examine
  Returns:
    the Number associated with this edge
  See Also:
    `NumberEdgeValue.getNumber(edu.uci.ics.jung.graph.ArchetypeEdge)`

### setNumber

    public void setNumber(ArchetypeEdge e,
                          Number n)

  Specified by:
    `setNumber` in interface `NumberEdgeValue`
  Parameters:
    `e` - the edge whose value we're setting
    `n` - the Number to which we're setting the edge
  See Also:
    `NumberEdgeValue.setNumber(edu.uci.ics.jung.graph.ArchetypeEdge, java.lang.Number)`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD