Class ArcListDiGraph<T>

java.lang.Object
it.unimi.di.prog2.h25.digraph.ArcListDiGraph<T>
Type Parameters:
T - the type of the graph nodes.
All Implemented Interfaces:
DiGraph<T>

public class ArcListDiGraph<T> extends Object implements DiGraph<T>
A directed graph implementation based on a list of Arcs and one of nodes.
  • Field Details

    • nodes

      private final Set<T> nodes
      The set of graph nodes.

      Observe that isolated nodes (node not appearing in any arc) belong to this set.

    • arcs

      private final Set<Arc<T>> arcs
      The set of graph arcs.
  • Constructor Details

    • ArcListDiGraph

      public ArcListDiGraph()
  • Method Details

    • addArc

      public void addArc(T source, T destination)
      Description copied from interface: DiGraph
      Adds an arc to this graph.

      It the source, or destination, node are not present in the graph, they are also added.

      Specified by:
      addArc in interface DiGraph<T>
      Parameters:
      source - the source of the arc to be added.
      destination - the destination of the arc to be added.
    • addNode

      public void addNode(T node)
      Description copied from interface: DiGraph
      Adds a node to this graph.
      Specified by:
      addNode in interface DiGraph<T>
      Parameters:
      node - the node to be added.
    • nodes

      public Set<T> nodes()
      Description copied from interface: DiGraph
      Returns the graph nodes.
      Specified by:
      nodes in interface DiGraph<T>
      Returns:
      the graph nodes.
    • arcs

      public Set<Arc<T>> arcs()
      Description copied from interface: DiGraph
      Returns this graph arcs.
      Specified by:
      arcs in interface DiGraph<T>
      Returns:
      the arcs belonging to this graph.