Package ghidra.graph
Class GraphPath<V>
java.lang.Object
ghidra.graph.GraphPath<V>
- Type Parameters:
V
- the vertex type.
Class for storing paths with fast "contains" method.
Note: a path can only contain a vertex once.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a vertex to the GraphPath.boolean
Check if vertex v is in the GraphPath.copy()
Creates a new GraphPath object by performing a shallow copy on another GraphPath object.int
Get the depth of the vertex that is specified by the parameter.get
(int depth) Get vertex that is specified by the parameter.getCommonStartPath
(GraphPath<V> other) Return all vertices that two GraphPaths have in common.getLast()
Get last vertex of GraphPath.getPredecessors
(V v) Return a set with all of the predecessors of the vertex in the GraphPath.getSuccessors
(V v) Return a set with all of the successors of the vertex in the GraphPath.Remove the last vertex of the GraphPath.int
size()
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.toString()
-
Constructor Details
-
GraphPath
public GraphPath()Default constructor. -
GraphPath
Constructor with a vertex.- Parameters:
v
- the first vertex of the newly initialized GraphPath object
-
-
Method Details
-
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
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
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
Check if vertex v is in the GraphPath.- Parameters:
v
- the vertex- Returns:
- true if vertex v is in this GraphPath
-
add
Add a vertex to the GraphPath.- Parameters:
v
- the new vertex
-
getLast
Get last vertex of GraphPath.- Returns:
- last vertex of GraphPath
-
depth
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
Get vertex that is specified by the parameter.- Parameters:
depth
- of the vertex to retrieve- Returns:
- the vertex
-
removeLast
Remove the last vertex of the GraphPath.- Returns:
- the removed vertex
-
getPredecessors
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
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
-
subPath
Get a part of the whole GraphPath, similar to substring with strings.- Parameters:
start
- the start of the sub-path of the GraphPathend
- 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
-