Class HashMutableDirectedGraph<N>

    • Field Detail

      • nodeToPreds

        protected final Map<N,​Set<N>> nodeToPreds
      • nodeToSuccs

        protected final Map<N,​Set<N>> nodeToSuccs
      • heads

        protected final Set<N> heads
      • tails

        protected final Set<N> tails
    • Constructor Detail

      • HashMutableDirectedGraph

        public HashMutableDirectedGraph()
    • Method Detail

      • clearAll

        public void clearAll()
        Removes all nodes and edges.
      • getPredsOf

        public List<N> getPredsOf​(N s)
        Description copied from interface: DirectedGraph
        Returns a list of predecessors for the given node in the graph.
        Specified by:
        getPredsOf in interface DirectedGraph<N>
      • getSuccsOf

        public List<N> getSuccsOf​(N s)
        Description copied from interface: DirectedGraph
        Returns a list of successors for the given node in the graph.
        Specified by:
        getSuccsOf in interface DirectedGraph<N>
      • size

        public int size()
        Description copied from interface: DirectedGraph
        Returns the node count for this graph.
        Specified by:
        size in interface DirectedGraph<N>
      • addEdge

        public void addEdge​(N from,
                            N to)
        Description copied from interface: MutableDirectedGraph
        Adds an edge to the graph between 2 nodes. If the edge is already present no change is made.
        Specified by:
        addEdge in interface MutableDirectedGraph<N>
        Parameters:
        from - out node for the edge.
        to - in node for the edge.
      • removeEdge

        public void removeEdge​(N from,
                               N to)
        Description copied from interface: MutableDirectedGraph
        Removes an edge between 2 nodes in the graph. If the edge is not present no change is made.
        Specified by:
        removeEdge in interface MutableDirectedGraph<N>
        Parameters:
        from - out node for the edge to remove.
        to - in node for the edge to remove.
      • containsEdge

        public boolean containsEdge​(N from,
                                    N to)
        Specified by:
        containsEdge in interface MutableDirectedGraph<N>
        Returns:
        true if the graph contains an edge the 2 nodes false otherwise.
      • containsNode

        public boolean containsNode​(N node)
        Specified by:
        containsNode in interface MutableDirectedGraph<N>
        Parameters:
        node - node that we want to know if the graph constains.
        Returns:
        true if the graph contains the node. false otherwise.
      • getNodes

        public List<N> getNodes()
        Specified by:
        getNodes in interface MutableDirectedGraph<N>
        Returns:
        a list of the nodes that compose the graph. No ordering is implied.
      • removeNode

        public void removeNode​(N node)
        Description copied from interface: MutableDirectedGraph
        Removes a node from the graph. If the node is not found in the graph, no change is made.
        Specified by:
        removeNode in interface MutableDirectedGraph<N>
        Parameters:
        node - the node to be removed.
      • printGraph

        public void printGraph()