com.opensymphony.xwork2.config.providers

## Class DirectedGraph<T>

- java.lang.Object
- - com.opensymphony.xwork2.config.providers.DirectedGraph<T>

- All Implemented Interfaces:
    Iterable<T>

      public final class DirectedGraph<T>
      extends Object
      implements Iterable<T>

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DirectedGraph()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addEdge(T start, T dest)` Given a start node, and a destination, adds an arc from the start node to the destination.
    `boolean` | `addNode(T node)` Adds a new node to the graph.
    `boolean` | `edgeExists(T start, T end)` Given two nodes in the graph, returns whether there is an edge from the first node to the second node.
    `Set<T>` | `edgesFrom(T node)` Given a node in the graph, returns an immutable view of the edges leaving that node as a set of endpoints.
    `boolean` | `isEmpty()` Returns whether the graph is empty.
    `Iterator<T>` | `iterator()` Returns an iterator that can traverse the nodes in the graph.
    `void` | `removeEdge(T start, T dest)` Removes the edge from start to dest from the graph.
    `int` | `size()` Returns the number of nodes in the graph.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface java.lang.Iterable

      `forEach, spliterator`

- - ### Constructor Detail

    - #### DirectedGraph

          public DirectedGraph()

  - ### Method Detail

    - #### addNode

          public boolean addNode(T node)

      Adds a new node to the graph. If the node already exists, this function is a no-op.
      Parameters:
        `node` - The node to add.
      Returns:
        Whether or not the node was added.

    - #### addEdge

          public void addEdge(T start,
                              T dest)

      Given a start node, and a destination, adds an arc from the start node to the destination. If an arc already exists, this operation is a no-op. If either endpoint does not exist in the graph, throws a NoSuchElementException.
      Parameters:
        `start` - The start node.
        `dest` - The destination node.
      Throws:
        `NoSuchElementException` - If either the start or destination nodes do not exist.

    - #### removeEdge

          public void removeEdge(T start,
                                 T dest)

      Removes the edge from start to dest from the graph. If the edge does not exist, this operation is a no-op. If either endpoint does not exist, this throws a NoSuchElementException.
      Parameters:
        `start` - The start node.
        `dest` - The destination node.
      Throws:
        `NoSuchElementException` - If either node is not in the graph.

    - #### edgeExists

          public boolean edgeExists(T start,
                                    T end)

      Given two nodes in the graph, returns whether there is an edge from the first node to the second node. If either node does not exist in the graph, throws a NoSuchElementException.
      Parameters:
        `start` - The start node.
        `end` - The destination node.
      Returns:
        Whether there is an edge from start to end.
      Throws:
        `NoSuchElementException` - If either endpoint does not exist.

    - #### edgesFrom

          public Set<T> edgesFrom(T node)

      Given a node in the graph, returns an immutable view of the edges leaving that node as a set of endpoints.
      Parameters:
        `node` - The node whose edges should be queried.
      Returns:
        An immutable view of the edges leaving that node.
      Throws:
        `NoSuchElementException` - If the node does not exist.

    - #### iterator

          public Iterator<T> iterator()

      Returns an iterator that can traverse the nodes in the graph.
      Specified by:
        `iterator` in interface `Iterable<T>`
      Returns:
        An iterator that traverses the nodes in the graph.

    - #### size

          public int size()

      Returns the number of nodes in the graph.
      Returns:
        The number of nodes in the graph.

    - #### isEmpty

          public boolean isEmpty()

      Returns whether the graph is empty.
      Returns:
        Whether the graph is empty.

Copyright © 2000–2023 Apache Software Foundation. All rights reserved.