Class DynamicGraph.Edges<T>

java.lang.Object
org.testng.internal.DynamicGraph.Edges<T>
Enclosing class:
DynamicGraph<T>

private static class DynamicGraph.Edges<T> extends Object
Manage edges and weights between nodes.
  • Field Details

  • Constructor Details

    • Edges

      private Edges()
  • Method Details

    • addEdge

      public void addEdge(int weight, T from, T to, boolean ignoreCycles)
    • fromNodes

      Set<T> fromNodes()
      Returns:
      the set of nodes that have outgoing edges.
    • from

      Map<T,Integer> from(T node)
    • to

      Map<T,Integer> to(T node)
    • findReversedEdge

      private 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 edge
      to - - 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(Set<T> nodes)
    • hasAllEdgesWithWeight

      boolean hasAllEdgesWithWeight(T node, int level)
    • removeEdgesFromMap

      private static <T> void removeEdgesFromMap(Map<T,Map<T,Integer>> map, Collection<T> nodes, T node)
      Remove edges from a map given a node and a list of destination nodes. Given:
      
       m_outgoingEdges:
          a -> b
               c
               d
       m_incomingEdges:
          b -> a
          c -> a
          d -> a
      
       
      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.
    • addEdgeToMap

      private static <T> void addEdgeToMap(Map<T,Map<T,Integer>> map, T n1, T n2, int weight)
    • getEdges

      Map<T,Map<T,Integer>> getEdges()
      Allow raw access to the edges, but protect inside unmodifiableMaps. This is for tests, toString and toDot.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • appendDotEdges

      void appendDotEdges(StringBuilder sb, Set<T> finished)