Class NodeGraph<T>

java.lang.Object
org.chsrobotics.lib.util.NodeGraph<T>
Type Parameters:
T - Data type that can be held by the nodes.

public class NodeGraph<T> extends Object
Class representing a set of interconnected nodes.
  • Constructor Details

    • NodeGraph

      public NodeGraph()
      Constructs a new NodeGraph.
  • Method Details

    • createNode

      public NodeGraph<T>.Node createNode(T data)
      Creates a new Node as part of this NodeGraph with the given data.
      Parameters:
      data - The data to initialize the node with.
      Returns:
      A new Node.
    • getConnectedNodes

      public List<NodeGraph<T>.Node> getConnectedNodes(NodeGraph<T>.Node node)
      Returns all other nodes connected to the given node.
      Parameters:
      node - The node to check for connections.
      Returns:
      All nodes connected to the given node.
    • getAllNodes

      public Collection<NodeGraph<T>.Node> getAllNodes()
      Returns all Nodes in the NodeGraph.
      Returns:
      A Collection of all Nodes in the graph.
    • connectNodes

      public void connectNodes(NodeGraph<T>.Node nodeA, NodeGraph<T>.Node nodeB)
      Creates a bi-directional connection between two given nodes.
      Parameters:
      nodeA - The first node to connect.
      nodeB - The second node to connect.