Package ghidra.graph
Interface GDirectedGraph<V,E extends GEdge<V>>
- Type Parameters:
V
- the type of verticesE
- 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
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 Summary
Modifier and TypeMethodDescriptionvoid
Add an edgeboolean
Add a vertexboolean
containsEdge
(E e) Test if the graph contains a given edgeboolean
containsEdge
(V from, V to) Test if the graph contains an edge from one given vertex to anotherboolean
containsVertex
(V v) Test if the graph contains a given vertexcopy()
Copy this graph.Creates a new instance of this graph with no vertices or edges.Locates the edge object for the two verticesint
Count the number of edges in the graphgetEdges()
Retrieve all the edgesdefault Collection
<E> Returns all edges connected to the given vertexgetInEdges
(V v) Compute the incident edges that end at the given vertexgetOutEdges
(V v) Compute the incident edges that start at the given vertexdefault Collection
<V> getPredecessors
(V v) Compute a vertex's predecessorsdefault Collection
<V> getSuccessors
(V v) Compute a vertex's successorsint
Count the number of vertices in the graphRetrieve all the verticesboolean
isEmpty()
Test if the graph is empty, i.e., contains no vertices or edgesboolean
removeEdge
(E e) Removes an edgevoid
removeEdges
(Iterable<E> edges) Removes the given edges from the graphboolean
removeVertex
(V v) Remove a vertexvoid
removeVertices
(Iterable<V> vertices) Removes the given vertices from the graph
-
Method Details
-
addVertex
Add a vertex- Parameters:
v
- the vertex- Returns:
- true if the add was successful, false otherwise
-
removeVertex
Remove a vertex- Parameters:
v
- the vertex- Returns:
- true
-
removeVertices
Removes the given vertices from the graph- Parameters:
vertices
- the vertices to remove
-
addEdge
Add an edge- Parameters:
e
- the edge
-
removeEdge
Removes an edge- Parameters:
e
- the edge- Returns:
- true if the graph contained the given edge
-
removeEdges
Removes the given edges from the graph- Parameters:
edges
- the edges to remove
-
findEdge
Locates the edge object for the two vertices- Parameters:
start
- the start vertexend
- 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
Test if the graph contains a given vertex- Parameters:
v
- the vertex- Returns:
- true if the vertex is in the graph, or false
-
containsEdge
Test if the graph contains a given edge- Parameters:
e
- the ege- Returns:
- true if the edge is in the graph, or false
-
containsEdge
Test if the graph contains an edge from one given vertex to another- Parameters:
from
- the source vertexto
- 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
Compute the incident edges that end at the given vertex- Specified by:
getInEdges
in interfaceGImplicitDirectedGraph<V,
E extends GEdge<V>> - Parameters:
v
- the destination vertex- Returns:
- the in-edges to the given vertex
-
getOutEdges
Compute the incident edges that start at the given vertex- Specified by:
getOutEdges
in interfaceGImplicitDirectedGraph<V,
E extends GEdge<V>> - Parameters:
v
- the source vertex- Returns:
- the out-edges from the given vertex
-
getIncidentEdges
Returns all edges connected to the given vertex- Parameters:
v
- the vertex- Returns:
- the edges
-
getPredecessors
Compute a vertex's predecessorsThe default implementation computes this from the in-edges
- Specified by:
getPredecessors
in interfaceGImplicitDirectedGraph<V,
E extends GEdge<V>> - Parameters:
v
- the destination vertex- Returns:
- the predecessors
-
getSuccessors
Compute a vertex's successorsThe default implementation compute this from the out-edges
- Specified by:
getSuccessors
in interfaceGImplicitDirectedGraph<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.
-
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
-