Package ghidra.graph

Interface GDirectedGraph<V,E extends GEdge<V>>

Type Parameters:
V - the type of vertices
E - the type of edges
All Superinterfaces:
GImplicitDirectedGraph<V,E>
All Known Subinterfaces:
VisualGraph<V,E>
All Known Implementing Classes:
DefaultVisualGraph, FilteringVisualGraph, GroupingVisualGraph, JungDirectedGraph, JungDirectedVisualGraph, JungToGDirectedGraphAdapter, MutableGDirectedGraphWrapper

public interface GDirectedGraph<V,E extends GEdge<V>> extends GImplicitDirectedGraph<V,E>
A directed graph Unlike GImplicitDirectedGraph, this graph is constructed explicitly in memory. Edges and vertices are added and removed like any other collection, and these elements represent the entirety of the graph at any given time.
  • Method Details

    • addVertex

      boolean addVertex(V v)
      Add a vertex
      Parameters:
      v - the vertex
      Returns:
      true if the add was successful, false otherwise
    • removeVertex

      boolean removeVertex(V v)
      Remove a vertex
      Parameters:
      v - the vertex
      Returns:
      true
    • removeVertices

      void removeVertices(Iterable<V> vertices)
      Removes the given vertices from the graph
      Parameters:
      vertices - the vertices to remove
    • addEdge

      void addEdge(E e)
      Add an edge
      Parameters:
      e - the edge
    • removeEdge

      boolean removeEdge(E e)
      Removes an edge
      Parameters:
      e - the edge
      Returns:
      true if the graph contained the given edge
    • removeEdges

      void removeEdges(Iterable<E> edges)
      Removes the given edges from the graph
      Parameters:
      edges - the edges to remove
    • findEdge

      E findEdge(V start, V end)
      Locates the edge object for the two vertices
      Parameters:
      start - the start vertex
      end - the end vertex
      Returns:
      the edge
    • getVertices

      Collection<V> getVertices()
      Retrieve all the vertices
      Returns:
      the vertices
    • getEdges

      Collection<E> getEdges()
      Retrieve all the edges
      Returns:
      the edges
    • containsVertex

      boolean containsVertex(V v)
      Test if the graph contains a given vertex
      Parameters:
      v - the vertex
      Returns:
      true if the vertex is in the graph, or false
    • containsEdge

      boolean containsEdge(E e)
      Test if the graph contains a given edge
      Parameters:
      e - the ege
      Returns:
      true if the edge is in the graph, or false
    • containsEdge

      boolean containsEdge(V from, V to)
      Test if the graph contains an edge from one given vertex to another
      Parameters:
      from - the source vertex
      to - the destination vertex
      Returns:
      true if such an edge exists, or false
    • isEmpty

      boolean isEmpty()
      Test if the graph is empty, i.e., contains no vertices or edges
      Returns:
      true if the graph is empty, or false
    • getVertexCount

      int getVertexCount()
      Count the number of vertices in the graph
      Returns:
      the count
    • getEdgeCount

      int getEdgeCount()
      Count the number of edges in the graph
      Returns:
      the count
    • getInEdges

      Collection<E> getInEdges(V v)
      Compute the incident edges that end at the given vertex
      Specified by:
      getInEdges in interface GImplicitDirectedGraph<V,E extends GEdge<V>>
      Parameters:
      v - the destination vertex
      Returns:
      the in-edges to the given vertex
    • getOutEdges

      Collection<E> getOutEdges(V v)
      Compute the incident edges that start at the given vertex
      Specified by:
      getOutEdges in interface GImplicitDirectedGraph<V,E extends GEdge<V>>
      Parameters:
      v - the source vertex
      Returns:
      the out-edges from the given vertex
    • getIncidentEdges

      default Collection<E> getIncidentEdges(V v)
      Returns all edges connected to the given vertex
      Parameters:
      v - the vertex
      Returns:
      the edges
    • getPredecessors

      default Collection<V> getPredecessors(V v)
      Compute a vertex's predecessors

      The default implementation computes this from the in-edges

      Specified by:
      getPredecessors in interface GImplicitDirectedGraph<V,E extends GEdge<V>>
      Parameters:
      v - the destination vertex
      Returns:
      the predecessors
    • getSuccessors

      default Collection<V> getSuccessors(V v)
      Compute a vertex's successors

      The default implementation compute this from the out-edges

      Specified by:
      getSuccessors in interface GImplicitDirectedGraph<V,E extends GEdge<V>>
      Parameters:
      v - the source vertex
      Returns:
      the successors
    • copy

      GDirectedGraph<V,E> copy()
      Copy this graph.

      Note: the vertices and edges in the copy may be the same instances in the new graph and not themselves copies.

      Specified by:
      copy in interface GImplicitDirectedGraph<V,E extends GEdge<V>>
      Returns:
      the new copy
    • emptyCopy

      GDirectedGraph<V,E> emptyCopy()
      Creates a new instance of this graph with no vertices or edges. This is useful when you wish to build a new graph using the same type as this graph.
      Returns:
      the new copy