Interface NeighbourFunction<H,V>

Type Parameters:
H - the node type whose neighbours are being requested
V - the neighbour type
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface NeighbourFunction<H,V>
Supplies the neighbours (or children) of a node.

This is the Java-facing form of Visitor's Neighbours[H, V] type class: it is the "how do we traverse" concern, completely decoupled from the domain. For an ordinary graph the two type parameters are the same, so a homogeneous adjacency is a NeighbourFunction<V, V>. They differ only for a tree whose root has a different type from its descendants — see Traversals.traverseTree(Object, NeighbourFunction, NeighbourFunction, Order).

The returned Iterable may be empty but must not be null. Its order is the order in which neighbours are offered to the traversal frontier, so it determines tie-breaking between equally eligible neighbours.

  • Method Summary

    Modifier and Type
    Method
    Description
    neighbours(H node)
    Returns the neighbours of node.
  • Method Details

    • neighbours

      Iterable<V> neighbours(H node)
      Returns the neighbours of node.
      Parameters:
      node - the node whose neighbours are wanted
      Returns:
      the neighbours, possibly empty, never null