Package org.testng.internal
Class DynamicGraph.Edges<T>
- java.lang.Object
-
- org.testng.internal.DynamicGraph.Edges<T>
-
- Enclosing class:
- DynamicGraph<T>
private static class DynamicGraph.Edges<T> extends java.lang.ObjectManage edges and weights between nodes.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<T,java.util.Map<T,java.lang.Integer>>m_incomingEdgesprivate java.util.Map<T,java.util.Map<T,java.lang.Integer>>m_outgoingEdges
-
Constructor Summary
Constructors Modifier Constructor Description privateEdges()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddEdge(int weight, T from, T to, boolean ignoreCycles)private static <T> voidaddEdgeToMap(java.util.Map<T,java.util.Map<T,java.lang.Integer>> map, T n1, T n2, int weight)(package private) voidappendDotEdges(java.lang.StringBuilder sb, java.util.Set<T> finished)private java.lang.IntegerfindReversedEdge(T from, T to)Return the weight of the edge in the graph that is the reversed direction of edge.(package private) java.util.Map<T,java.lang.Integer>from(T node)(package private) java.util.Set<T>fromNodes()(package private) java.util.Map<T,java.util.Map<T,java.lang.Integer>>getEdges()Allow raw access to the edges, but protect inside unmodifiableMaps.(package private) intgetLowestEdgeWeight(java.util.Set<T> nodes)(package private) booleanhasAllEdgesWithWeight(T node, int level)private static <T> voidremoveEdgesFromMap(java.util.Map<T,java.util.Map<T,java.lang.Integer>> map, java.util.Collection<T> nodes, T node)Remove edges from a map given a node and a list of destination nodes.(package private) voidremoveNode(T node)Remove a node from the graph and all associated edges.(package private) java.util.Map<T,java.lang.Integer>to(T node)java.lang.StringtoString()
-
-
-
Method Detail
-
fromNodes
java.util.Set<T> fromNodes()
- Returns:
- the set of nodes that have outgoing edges.
-
findReversedEdge
private java.lang.Integer findReversedEdge(T from, T to)
Return the weight of the edge in the graph that is the reversed direction of edge. For example, if edge a -> b exists, and edge b -> a is passed in, then return a -> b.- Parameters:
from- - the from edgeto- - the to edge- Returns:
- the weight of the reversed edge or null if edge does not exist
-
removeNode
void removeNode(T node)
Remove a node from the graph and all associated edges. Each edge needs to be removed from both maps to keep the maps in sync.- Parameters:
node- Node to remove.
-
getLowestEdgeWeight
int getLowestEdgeWeight(java.util.Set<T> nodes)
-
hasAllEdgesWithWeight
boolean hasAllEdgesWithWeight(T node, int level)
-
removeEdgesFromMap
private static <T> void removeEdgesFromMap(java.util.Map<T,java.util.Map<T,java.lang.Integer>> map, java.util.Collection<T> nodes, T node)Remove edges from a map given a node and a list of destination nodes. Given:
Then, calling this method to remove node c on both maps as done in removeNode(), would result in a -> c and c -> a edges being removed.m_outgoingEdges: a -> b c d m_incomingEdges: b -> a c -> a d -> a
-
addEdgeToMap
private static <T> void addEdgeToMap(java.util.Map<T,java.util.Map<T,java.lang.Integer>> map, T n1, T n2, int weight)
-
getEdges
java.util.Map<T,java.util.Map<T,java.lang.Integer>> getEdges()
Allow raw access to the edges, but protect inside unmodifiableMaps. This is for tests, toString and toDot.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
appendDotEdges
void appendDotEdges(java.lang.StringBuilder sb, java.util.Set<T> finished)
-
-