Class DirectedGraph<T>

  • Type Parameters:
    T - the generic type
    All Implemented Interfaces:
    Iterable<T>

    public final class DirectedGraph<T>
    extends Object
    implements Iterable<T>
    The Class DirectedGraph.
    • Constructor Detail

      • DirectedGraph

        public DirectedGraph()
    • Method Detail

      • addEdge

        public boolean addEdge​(T start,
                               T end)
        Adds the edge.
        Parameters:
        start - the start
        end - the dest
      • addNode

        public boolean addNode​(T node)
        Adds the node.
        Parameters:
        node - the node
        Returns:
        true, if successful
      • clear

        public void clear()
      • edgeExists

        public boolean edgeExists​(T start,
                                  T end)
        Edge exists.
        Parameters:
        start - the start
        end - the end
        Returns:
        true, if successful
      • edgesFrom

        public Set<T> edgesFrom​(T node)
        Edges from.
        Parameters:
        node - the node
        Returns:
        the sets the
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • isEmpty

        public boolean isEmpty()
        Checks if is empty.
        Returns:
        true, if is empty
      • 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.
      • nodeExists

        public boolean nodeExists​(T node)
        Node exists.
        Parameters:
        node - the node
        Returns:
        true, if successful
      • size

        public int size()
        Size.
        Returns:
        the int