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

## toxi.util.datatypes
Class UndirectedGraph<N>

    java.lang.Object
      toxi.util.datatypes.UndirectedGraph<N>

    public class UndirectedGraph<N>

extends java.lang.Object

Straightforward undirected graph implementation. Nodes are generic type N.

Constructor Summary
`UndirectedGraph()`

Method Summary
`void` | `add(N node)` Add a node.
`void` | `connect(N nodeA, N nodeB)` Add a link.
`void` | `disconnect(N nodeA, N nodeB)` Remove the specified link.
`java.util.Set<N>` | `getConnectedNodesFor(N node)` Report all the neighbors of node.
`java.util.Set<N>` | `getNodes()` Returns an unmodifiable Set view of the nodes contained in this graph.
`void` | `remove(N node)` Remove node and any links that use node.

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

Constructor Detail

### UndirectedGraph

    public UndirectedGraph()

Method Detail

### add

    public void add(N node)

  Add a node. If node is already in graph then no change.

  Parameters:
    `node` - the node to add

### connect

    public void connect(N nodeA,
                        N nodeB)
                 throws java.lang.NullPointerException

  Add a link. If the link is already in graph then no change.

  Parameters:
    `nodeA` - one end of the link
    `nodeB` - the other end of the link
  Throws:
    `java.lang.NullPointerException` - if either endpoint is not in graph

### disconnect

    public void disconnect(N nodeA,
                           N nodeB)
                    throws java.lang.NullPointerException

  Remove the specified link. If link not in graph, nothing happens.

  Parameters:
    `nodeA` - one end of the link
    `nodeB` - the other end of the link
  Throws:
    `java.lang.NullPointerException` - if either endpoint is not in graph

### getConnectedNodesFor

    public java.util.Set<N> getConnectedNodesFor(N node)
                                          throws java.lang.NullPointerException

  Report all the neighbors of node.

  Parameters:
    `node` - the node
  Returns:
    the neighbors of node
  Throws:
    `java.lang.NullPointerException` - if node does not appear in graph

### getNodes

    public java.util.Set<N> getNodes()

  Returns an unmodifiable Set view of the nodes contained in this graph. The set is backed by the graph, so changes to the graph are reflected in the set.

  Returns:
    a Set view of the graph's node set

### remove

    public void remove(N node)

  Remove node and any links that use node. If node not in graph, nothing happens.

  Parameters:
    `node` - the node to remove.

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