Interface Graph<G extends Graph<G,​N,​E>,​N extends Node<G,​N,​E>,​E extends Edge<G,​N,​E>>

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default <V> void accept​(GraphVisitor<G,​N,​E,​V> visitor, V tool)
      Accepts the given GraphVisitor.
      void addEdge​(E edge)
      Adds an edge to this graph.
      void addNode​(N node)
      Adds the given node to the set of nodes.
      void addNode​(N node, boolean entrypoint)
      Adds the given node to the set of nodes, optionally marking this as entrypoint (that is, root).
      boolean containsEdge​(E edge)
      Yields true if the given edge is contained in this graph.
      boolean containsNode​(N node)
      Yields true if the given node is contained in this graph.
      java.util.Collection<N> followersOf​(N node)
      Yields the collection of the nodes that are followers of the given one, that is, all nodes such that there exist an edge in this control flow graph going from the given node to such node.
      default java.util.Collection<N> getCycleEntries()
      Yields all the nodes that are part of cycles in the graph that are also reachable from outside the cycle itself (that is, if they are also entrypoints or if they have an incoming back-edge).
      E getEdgeConnecting​(N source, N destination)
      Yields the edge connecting the two given nodes, if any.
      java.util.Collection<E> getEdges()
      Yields the set of edges of this graph.
      java.util.Collection<E> getEdgesConnecting​(N source, N destination)
      Yields all edges connecting the two given nodes, if any.
      int getEdgesCount()
      Yields the total number of edges of this graph.
      java.util.Collection<N> getEntrypoints()
      Yields the nodes of this graph that are entrypoints, that is, roots of the graph.
      java.util.Collection<E> getIngoingEdges​(N node)
      Yields the ingoing edges to the given node.
      java.util.Collection<N> getNodes()
      Yields the set of nodes of this graph.
      int getNodesCount()
      Yields the total number of nodes of this graph.
      java.util.Collection<E> getOutgoingEdges​(N node)
      Yields the outgoing edges from the given node.
      boolean isEqualTo​(G graph)
      Checks if this graph is effectively equal to the given one, that is, if they have the same structure while potentially being different instances.
      java.util.Collection<N> predecessorsOf​(N node)
      Yields the collection of the nodes that are predecessors of the given vertex, that is, all nodes such that there exist an edge in this control flow graph going from such node to the given one.
      default SerializableGraph toSerializableGraph()
      Yields an instance of SerializableGraph built from this one.
      SerializableGraph toSerializableGraph​(java.util.function.BiFunction<G,​N,​SerializableValue> descriptionGenerator)
      Yields an instance of SerializableGraph built from this one.
    • Method Detail

      • getEntrypoints

        java.util.Collection<N> getEntrypoints()
        Yields the nodes of this graph that are entrypoints, that is, roots of the graph. This usually contains the first node of this graph, but might also contain other ones.
        Returns:
        the entrypoints of this graph
      • getNodes

        java.util.Collection<N> getNodes()
        Yields the set of nodes of this graph.
        Returns:
        the collection of nodes
      • getEdges

        java.util.Collection<E> getEdges()
        Yields the set of edges of this graph.
        Returns:
        the collection of edges
      • addNode

        void addNode​(N node)
        Adds the given node to the set of nodes. This is equivalent to invoking addNode(Node, boolean) with false as second parameter.
        Parameters:
        node - the node to add
      • addNode

        void addNode​(N node,
                     boolean entrypoint)
        Adds the given node to the set of nodes, optionally marking this as entrypoint (that is, root).
        Parameters:
        node - the node to add
        entrypoint - if true causes the given node to be considered as an entrypoint.
      • addEdge

        void addEdge​(E edge)
        Adds an edge to this graph.
        Parameters:
        edge - the edge to add
        Throws:
        java.lang.UnsupportedOperationException - if the source or the destination of the given edge are not part of this graph
      • getNodesCount

        int getNodesCount()
        Yields the total number of nodes of this graph.
        Returns:
        the number of nodes
      • getEdgesCount

        int getEdgesCount()
        Yields the total number of edges of this graph.
        Returns:
        the number of edges
      • containsNode

        boolean containsNode​(N node)
        Yields true if the given node is contained in this graph.
        Parameters:
        node - the node to check
        Returns:
        true if the node is in this graph
      • containsEdge

        boolean containsEdge​(E edge)
        Yields true if the given edge is contained in this graph.
        Parameters:
        edge - the edge to check
        Returns:
        true if the edge is in this graph
      • getEdgeConnecting

        E getEdgeConnecting​(N source,
                            N destination)
        Yields the edge connecting the two given nodes, if any. Yields null if such edge does not exist, or if one of the two nodes is not inside this graph. If more than one edge connects the two nodes, this method returns one of them arbitrarily (but consistently: successive calls with the same parameters will always return the same edge). To retrieve all such edges, use getEdgesConnecting(Node, Node).
        Parameters:
        source - the source node
        destination - the destination node
        Returns:
        the edge connecting source to destination, or null
      • getEdgesConnecting

        java.util.Collection<E> getEdgesConnecting​(N source,
                                                   N destination)
        Yields all edges connecting the two given nodes, if any. Yields an empty collection if no edge exists, or if one of the two nodes is not inside this graph.
        Parameters:
        source - the source node
        destination - the destination node
        Returns:
        the edges connecting source to destination
      • getIngoingEdges

        java.util.Collection<E> getIngoingEdges​(N node)
        Yields the ingoing edges to the given node.
        Parameters:
        node - the node
        Returns:
        the collection of ingoing edges
      • getOutgoingEdges

        java.util.Collection<E> getOutgoingEdges​(N node)
        Yields the outgoing edges from the given node.
        Parameters:
        node - the node
        Returns:
        the collection of outgoing edges
      • followersOf

        java.util.Collection<N> followersOf​(N node)
        Yields the collection of the nodes that are followers of the given one, that is, all nodes such that there exist an edge in this control flow graph going from the given node to such node. Yields null if the node is not in this graph.
        Parameters:
        node - the node
        Returns:
        the collection of followers
      • predecessorsOf

        java.util.Collection<N> predecessorsOf​(N node)
        Yields the collection of the nodes that are predecessors of the given vertex, that is, all nodes such that there exist an edge in this control flow graph going from such node to the given one. Yields null if the node is not in this graph.
        Parameters:
        node - the node
        Returns:
        the collection of predecessors
      • isEqualTo

        boolean isEqualTo​(G graph)
        Checks if this graph is effectively equal to the given one, that is, if they have the same structure while potentially being different instances.
        Parameters:
        graph - the other graph
        Returns:
        true if this graph and the given one are effectively equals
      • getCycleEntries

        default java.util.Collection<N> getCycleEntries()
        Yields all the nodes that are part of cycles in the graph that are also reachable from outside the cycle itself (that is, if they are also entrypoints or if they have an incoming back-edge).
        Returns:
        the nodes that are cycle entries