Class UndirectedGraph<N>

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

public class UndirectedGraph<N> extends Object
Straightforward undirected graph implementation. Nodes are generic type N.
Author:
Paul Chew Created November, December 2007. For use in Delaunay/Voronoi code., toxi Updated July 2010, minor API changes to be better suited for toxiclibs
  • Constructor Details

    • UndirectedGraph

      public UndirectedGraph()
  • Method Details

    • 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 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:
      NullPointerException - if either endpoint is not in graph
    • disconnect

      public void disconnect(N nodeA, N nodeB) throws 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:
      NullPointerException - if either endpoint is not in graph
    • getConnectedNodesFor

      public Set<N> getConnectedNodesFor(N node) throws NullPointerException
      Report all the neighbors of node.
      Parameters:
      node - the node
      Returns:
      the neighbors of node
      Throws:
      NullPointerException - if node does not appear in graph
    • getNodes

      public 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.