Interface DirectedGraph<V,A>

Type Parameters:
V - the vertex data type
A - the arrow data type
All Superinterfaces:
BareDirectedGraph<V,A>, BareDirectedVertexGraph<V>
All Known Subinterfaces:
BidiGraph<V,A>, MutableBidiGraph<V,A>, MutableDirectedGraph<V,A>
All Known Implementing Classes:
ImmutableAttributed16BitIndexedDirectedGraph, ImmutableAttributed32BitIndexedBidiGraph, ImmutableAttributed32BitIndexedDirectedGraph, IndexedBidiGraphBidiGraphFacade, IndexedDirectedGraphDirectedGraphFacade, SimpleMutableBidiGraph, SimpleMutableDirectedGraph

public interface DirectedGraph<V,A> extends BareDirectedGraph<V,A>
Adds convenience methods to the interface defined in BareDirectedGraph.
Author:
Werner Randelshofer
  • Method Details

    • findArrow

      default @Nullable A findArrow(@NonNull V u, @NonNull V v)
      Returns the arrow data for the arrow going from u to v if the arrow exists.
      Parameters:
      u - a vertex
      v - a vertex
      Returns:
      the arrow data or null
    • findIndexOfNext

      default int findIndexOfNext(@NonNull V v, @NonNull V u)
      Returns the index of vertex u in the list of next vertices of v if an arrow from v to u exists.
      Parameters:
      v - a vertex
      u - a vertex
      Returns:
      index of vertex u or a value < 0
    • getNextVertices

      default @NonNull Collection<V> getNextVertices(@NonNull V v)
      Returns the list of next vertices of vertex v.
      Parameters:
      v - a vertex
      Returns:
      a collection view on the direct successor vertices of vertex
    • getNextArc

      default @NonNull Arc<V,A> getNextArc(@NonNull V v, int i)
      Returns the arc data for the i-th next (outgoing) arrow from vertex v.
      Parameters:
      v - a vertex
      i - the index into the list of outgoing arrows
      Returns:
      the arc data
    • getNextArrows

      default @NonNull Collection<A> getNextArrows(@NonNull V v)
      Returns the list of next arrow data of vertex v.
      Parameters:
      v - a vertex
      Returns:
      a collection view on the arrow data
    • getNextArcs

      default @NonNull Collection<Arc<V,A>> getNextArcs(@NonNull V v)
      Returns the list of next arc data of vertex v.
      Parameters:
      v - a vertex
      Returns:
      a collection view on the arc data
    • getVertexCount

      default int getVertexCount()
      Returns the number of vertices.
      Returns:
      vertex count
    • getArrowCount

      int getArrowCount()
      Returns the number of arrows.
      Returns:
      arrow count
    • getArrows

      default @NonNull Collection<A> getArrows(@NonNull V v1, V v2)
      Returns all arrows between two vertices.
      Parameters:
      v1 - vertex 1
      v2 - vertex 2
      Returns:
      a collection of all arrows
    • getArrows

      default @NonNull Collection<A> getArrows()
      Returns all arrows.
      Returns:
      a collection of all arrows
    • isNext

      default boolean isNext(@NonNull V v, @NonNull V u)
      Returns true if there is an arrow from vertex v to vertex u.
      Parameters:
      v - a vertex
      u - a vertex
      Returns:
      true if u is next of v
    • getVertex

      @NonNull V getVertex(int index)
      Gets the vertex data at the specified index.
      Parameters:
      index - an index
      Returns:
      vertex data
      Throws:
      IndexOutOfBoundsException - if the index is out of bounds
    • searchNextVertices

      default @NonNull Enumerator<V> searchNextVertices(@NonNull V start, boolean dfs)
      Searches for vertices starting at the provided vertex.
      Parameters:
      start - the start vertex
      dfs - whether to search depth-first instead of breadth-first
      Returns:
      breadth first search
    • searchNextVertices

      default @NonNull Enumerator<V> searchNextVertices(@NonNull V start, @NonNull AddToSet<V> visited, boolean dfs)
      Searches for vertices starting at the provided vertex.
      Parameters:
      start - the start vertex
      visited - the add method of the visited set, see Set.add(E).
      dfs - whether to search depth-first instead of breadth-first
      Returns:
      breadth first search