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
public interface GDirectedGraph<V,E extends GEdge<V>> extends GImplicitDirectedGraph<V,E>
A directed graph UnlikeGImplicitDirectedGraph
, 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
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
addEdge(E e)
Add an edgeboolean
addVertex(V v)
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 vertexGDirectedGraph<V,E>
copy()
Copy this graph.GDirectedGraph<V,E>
emptyCopy()
Creates a new instance of this graph with no vertices or edges.E
findEdge(V start, V end)
Locates the edge object for the two verticesint
getEdgeCount()
Count the number of edges in the graphjava.util.Collection<E>
getEdges()
Retrieve all the edgesdefault java.util.Collection<E>
getIncidentEdges(V v)
Returns all edges connected to the given vertexjava.util.Collection<E>
getInEdges(V v)
Compute the incident edges that end at the given vertexjava.util.Collection<E>
getOutEdges(V v)
Compute the incident edges that start at the given vertexdefault java.util.Collection<V>
getPredecessors(V v)
Compute a vertex's predecessorsdefault java.util.Collection<V>
getSuccessors(V v)
Compute a vertex's successorsint
getVertexCount()
Count the number of vertices in the graphjava.util.Collection<V>
getVertices()
Retrieve all the verticesboolean
isEmpty()
Test if the graph is empty, i.e., contains no vertices or edgesboolean
removeEdge(E e)
Removes an edgevoid
removeEdges(java.lang.Iterable<E> edges)
Removes the given edges from the graphboolean
removeVertex(V v)
Remove a vertexvoid
removeVertices(java.lang.Iterable<V> vertices)
Removes the given vertices from the graph
-
-
-
Method Detail
-
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(java.lang.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(java.lang.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 vertexend
- the end vertex- Returns:
- the edge
-
getVertices
java.util.Collection<V> getVertices()
Retrieve all the vertices- Returns:
- the vertices
-
getEdges
java.util.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 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
java.util.Collection<E> getInEdges(V v)
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
java.util.Collection<E> getOutEdges(V v)
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
default java.util.Collection<E> getIncidentEdges(V v)
Returns all edges connected to the given vertex- Parameters:
v
- the vertex- Returns:
- the edges
-
getPredecessors
default java.util.Collection<V> getPredecessors(V v)
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
default java.util.Collection<V> getSuccessors(V v)
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
-
-