Package ghidra.graph

Class GraphPath<V>

java.lang.Object
ghidra.graph.GraphPath<V>
Type Parameters:
V - the vertex type.

public class GraphPath<V> extends Object
Class for storing paths with fast "contains" method.

Note: a path can only contain a vertex once.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor.
    Constructor with a vertex.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(V v)
    Add a vertex to the GraphPath.
    boolean
    Check if vertex v is in the GraphPath.
    Creates a new GraphPath object by performing a shallow copy on another GraphPath object.
    int
    depth(V v)
    Get the depth of the vertex that is specified by the parameter.
    get(int depth)
    Get vertex that is specified by the parameter.
    Return all vertices that two GraphPaths have in common.
    Get last vertex of GraphPath.
    Return a set with all of the predecessors of the vertex in the GraphPath.
    Return a set with all of the successors of the vertex in the GraphPath.
    Remove the last vertex of the GraphPath.
    int
    Return the size of the GraphPath.
    boolean
    startsWith(GraphPath<V> otherPath)
    Check if a GraphPath starts with another GraphPath.
    subPath(int start, int end)
    Get a part of the whole GraphPath, similar to substring with strings.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • GraphPath

      public GraphPath()
      Default constructor.
    • GraphPath

      public GraphPath(V v)
      Constructor with a vertex.
      Parameters:
      v - the first vertex of the newly initialized GraphPath object
  • Method Details

    • copy

      public GraphPath<V> copy()
      Creates a new GraphPath object by performing a shallow copy on another GraphPath object.
      Returns:
      the new shallow copy of the original GraphPath object
    • startsWith

      public boolean startsWith(GraphPath<V> otherPath)
      Check if a GraphPath starts with another GraphPath.
      Parameters:
      otherPath - the other GraphPath we are checking
      Returns:
      true if the current GraphPath starts with otherPath, false otherwise
    • getCommonStartPath

      public GraphPath<V> getCommonStartPath(GraphPath<V> other)
      Return all vertices that two GraphPaths have in common. For example if you have a-b-c-d-e-f and a-b-c-d-k-l-z, the common start path will be a-b-c-d. If there is no common start path, an empty GraphPath object is returned.
      Parameters:
      other - the other GraphPath to get the common start path of
      Returns:
      a new GraphPath object containing the common start path vertices
    • size

      public int size()
      Return the size of the GraphPath.
      Returns:
      size of the GraphPath
    • contains

      public boolean contains(V v)
      Check if vertex v is in the GraphPath.
      Parameters:
      v - the vertex
      Returns:
      true if vertex v is in this GraphPath
    • add

      public void add(V v)
      Add a vertex to the GraphPath.
      Parameters:
      v - the new vertex
    • getLast

      public V getLast()
      Get last vertex of GraphPath.
      Returns:
      last vertex of GraphPath
    • depth

      public int depth(V v)
      Get the depth of the vertex that is specified by the parameter.
      Parameters:
      v - the vertex for which we get the depth
      Returns:
      the depth of the vertex
    • get

      public V get(int depth)
      Get vertex that is specified by the parameter.
      Parameters:
      depth - of the vertex to retrieve
      Returns:
      the vertex
    • removeLast

      public V removeLast()
      Remove the last vertex of the GraphPath.
      Returns:
      the removed vertex
    • getPredecessors

      public Set<V> getPredecessors(V v)
      Return a set with all of the predecessors of the vertex in the GraphPath.
      Parameters:
      v - the vertex we want to get the predecessors of
      Returns:
      the predecessors of the vertex as a set, return empty set if there are none
    • getSuccessors

      public Set<V> getSuccessors(V v)
      Return a set with all of the successors of the vertex in the GraphPath.
      Parameters:
      v - the vertex we want to get the successors of
      Returns:
      the successors of the vertex as a set, return empty set if there are none
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • subPath

      public GraphPath<V> subPath(int start, int end)
      Get a part of the whole GraphPath, similar to substring with strings.
      Parameters:
      start - the start of the sub-path of the GraphPath
      end - the end of the sub-path of the GraphPath
      Returns:
      a new GraphPath which is a sub-path of the original GraphPath from start to end