Package ghidra.util.graph
Class WeightedDigraph
- java.lang.Object
-
- ghidra.util.graph.DirectedGraph
-
- ghidra.util.graph.WeightedDigraph
-
- Direct Known Subclasses:
SimpleWeightedDigraph
public class WeightedDigraph extends DirectedGraph
DirectedGraph with edge weights. Weights are assumed to be 0.0 by default.
-
-
Constructor Summary
Constructors Constructor Description WeightedDigraph()
Default constructorWeightedDigraph(int vertexCapacity, int edgeCapacity)
Create weighted directed graph with default edge weight of 0.0 and room for vertexCapicity vertices and edgeCapacity edges.WeightedDigraph(int vertexCapacity, int edgeCapacity, double defaultEdgeWeight)
Create a weighted directed graph.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(Edge e)
Add an edge.boolean
add(Edge e, double weight)
Add an edge.DirectedGraph
copy()
double
degree(Vertex v)
Returns the weighted degree of this vertex.double
getDefaultEdgeWeight()
Gets the defaultEdgeWeight of this graph specified at creation time.DoubleAttribute<Edge>
getEdgeWeights()
Get the edge weights for this graph.double
getWeight(Edge e)
Returns the weight of the specified edge.double
inDegree(Vertex v)
Returns the weighted in-degree of this vertex.void
intersectionWith(DirectedGraph otherGraph)
Creates intersection of graphs in place by adding all vertices and edges of other graph to this graph.double
outDegree(Vertex v)
Returns the weighted out-degree of this vertex.double
selfDegree(Vertex v)
Returns the weighted self-degree of this vertex.boolean
setWeight(Edge e, double value)
Sets the weight of the specified edge.void
unionWith(DirectedGraph otherGraph)
Creates union of graphs in place by adding all vertices and edges of other graph to this graph.-
Methods inherited from class ghidra.util.graph.DirectedGraph
add, areRelatedAs, assignVerticesToStrongComponents, clear, complexityDepth, contains, contains, containsAsSubgraph, copyAll, copyEdge, copyEdgeAttributeValues, copyVertex, copyVertexAttributeValues, descendantsGraph, edgeAttributes, edgeIterator, edges, getAncestors, getChildren, getChildren, getComponentContaining, getComponents, getDescendants, getDescendants, getEdgeArray, getEdgeAttribute, getEdgeProperty, getEdges, getEdges, getEdgeWithKey, getEntryPoints, getIncomingEdges, getLevels, getNeighborhood, getNeighborhood, getOutgoingEdges, getParents, getParents, getReferent, getSinks, getSources, getVertexArray, getVertexAttribute, getVertexProperty, getVertexWithKey, getVertices, getVerticesHavingReferent, getVerticesInContainingComponent, incomingEdges, inducedSubgraph, inValence, join, loopDegree, numEdges, numLoops, numSinks, numSources, numVertices, outgoingEdges, outValence, remove, remove, selfEdges, setEdgeProperty, setVertexProperty, valence, vertexAttributes, vertexIterator, vertices, verticesUnreachableFromSources, verts2referentSet
-
-
-
-
Constructor Detail
-
WeightedDigraph
public WeightedDigraph(int vertexCapacity, int edgeCapacity)
Create weighted directed graph with default edge weight of 0.0 and room for vertexCapicity vertices and edgeCapacity edges.
-
WeightedDigraph
public WeightedDigraph(int vertexCapacity, int edgeCapacity, double defaultEdgeWeight)
Create a weighted directed graph. Use the defaultEdgeWeight for any edges whose weights have not been set.
-
WeightedDigraph
public WeightedDigraph()
Default constructor
-
-
Method Detail
-
inDegree
public double inDegree(Vertex v)
Returns the weighted in-degree of this vertex. The in-degree is the sum of weights of all enges entering this vertex.- Overrides:
inDegree
in classDirectedGraph
-
outDegree
public double outDegree(Vertex v)
Returns the weighted out-degree of this vertex. The out-degree is the sum of weights of all enges entering this vertex.- Overrides:
outDegree
in classDirectedGraph
-
selfDegree
public double selfDegree(Vertex v)
Returns the weighted self-degree of this vertex. The self-degree is the sum of weights of all loops at this vertex.
-
degree
public double degree(Vertex v)
Returns the weighted degree of this vertex. The degree is the sum of weights of all edges entering and leaving this vertex.- Overrides:
degree
in classDirectedGraph
-
getWeight
public double getWeight(Edge e)
Returns the weight of the specified edge.
-
setWeight
public boolean setWeight(Edge e, double value)
Sets the weight of the specified edge.
-
getDefaultEdgeWeight
public double getDefaultEdgeWeight()
Gets the defaultEdgeWeight of this graph specified at creation time.
-
add
public boolean add(Edge e)
Add an edge. If successful (i.e. that edge does not already appear in the graph), set the weight to the default value- Overrides:
add
in classDirectedGraph
- Returns:
- true if edge added succesfuly.
-
add
public boolean add(Edge e, double weight)
Add an edge. If successful (i.e. that edge does not appear in the graph), then set the weight to the specified value.- Returns:
- true if edge added succesfuly.
-
getEdgeWeights
public DoubleAttribute<Edge> getEdgeWeights()
Get the edge weights for this graph.
-
copy
public DirectedGraph copy()
- Overrides:
copy
in classDirectedGraph
- Returns:
- A directed graph with the same vertices, edges, and attributes.
-
intersectionWith
public void intersectionWith(DirectedGraph otherGraph)
Creates intersection of graphs in place by adding all vertices and edges of other graph to this graph. This method used to return a different graph as the intersection but now does not.- Overrides:
intersectionWith
in classDirectedGraph
-
unionWith
public void unionWith(DirectedGraph otherGraph)
Creates union of graphs in place by adding all vertices and edges of other graph to this graph. This method used to return a different graph as the union but now does not.- Overrides:
unionWith
in classDirectedGraph
-
-