APIdia Launch Partner
Top Inners Fields Constructors Methods
com.sun.tools.jdeps

public final Class Graph<T>

extends Object
Class Inheritance
Imports
java.io.PrintWriter, java.util.ArrayDeque, .Collections, .Deque, .HashMap, .HashSet, .Map, .Set, java.util.function.Consumer, java.util.stream.Collectors, .Stream

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv static class
pack-priv static class
Graph.TopoSorter<T>

Topological sort

Field Summary

Modifier and TypeField and Description
private final Map<T, Set<T>>
private final Set<T>

Constructor Summary

AccessConstructor and Description
public
Graph(Set<T> nodes, Map<T, Set<T>> edges)

Method Summary

Modifier and TypeMethod and Description
public Set<T>
public boolean
contains(T u)

public Set<T>
dfs(Set<T> roots)

Returns all nodes reachable from the given set of roots.

public Map<T, Set<T>>
public Set<Graph.Edge<T>>
edgesFrom(T u)

private boolean
isAdjacent(T u, T v)

public Set<T>
public void
ordered(Consumer<T> action)

Traverse this graph and performs the given action in topological order

public Stream<T>
orderedNodes()

Returns nodes sorted in topological order.

private boolean
pathExists(T u, T v)

private boolean
pathExists(T u, T v, boolean includeAdjacent)

Returns true if there exists a path from u to v in this graph.

public void
public Graph<T>
reduce()

Returns a new Graph after transitive reduction

public Graph<T>
reduce(Graph<T> g)

Returns a new Graph after transitive reduction.

public void
reverse(Consumer<T> action)

Traverses this graph and performs the given action in reverse topological order

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public Graph<T>
transpose()

Returns a transposed graph from this graph

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

edgesback to summary
private final Map<T, Set<T>> edges
nodesback to summary
private final Set<T> nodes

Constructor Detail

Graphback to summary
public Graph(Set<T> nodes, Map<T, Set<T>> edges)

Method Detail

adjacentNodesback to summary
public Set<T> adjacentNodes(T u)
containsback to summary
public boolean contains(T u)
dfsback to summary
public Set<T> dfs(Set<T> roots)

Returns all nodes reachable from the given set of roots.

edgesback to summary
public Map<T, Set<T>> edges()
edgesFromback to summary
public Set<Graph.Edge<T>> edgesFrom(T u)
isAdjacentback to summary
private boolean isAdjacent(T u, T v)
nodesback to summary
public Set<T> nodes()
orderedback to summary
public void ordered(Consumer<T> action)

Traverse this graph and performs the given action in topological order

orderedNodesback to summary
public Stream<T> orderedNodes()

Returns nodes sorted in topological order.

pathExistsback to summary
private boolean pathExists(T u, T v)
pathExistsback to summary
private boolean pathExists(T u, T v, boolean includeAdjacent)

Returns true if there exists a path from u to v in this graph. If includeAdjacent is false, it returns true if there exists another path from u to v of distance > 1

printGraphback to summary
public void printGraph(PrintWriter out)
reduceback to summary
public Graph<T> reduce()

Returns a new Graph after transitive reduction

reduceback to summary
public Graph<T> reduce(Graph<T> g)

Returns a new Graph after transitive reduction. All edges in the given g takes precedence over this graph.

Exceptions
IllegalArgumentException:
g must be a subgraph this graph
reverseback to summary
public void reverse(Consumer<T> action)

Traverses this graph and performs the given action in reverse topological order

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
transposeback to summary
public Graph<T> transpose()

Returns a transposed graph from this graph

com.sun.tools.jdeps back to summary

pack-priv Class Graph.Builder<T>

extends Object
Class Inheritance
Known Direct Subclasses
com.sun.tools.jdeps.ModuleGraphBuilder

Field Summary

Modifier and TypeField and Description
pack-priv final Map<T, Set<T>>
pack-priv final Set<T>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
addEdge(T u, T v)

public void
addNode(T node)

public void
addNodes(Set<T> nodes)

public Graph<T>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

edgesback to summary
pack-priv final Map<T, Set<T>> edges
nodesback to summary
pack-priv final Set<T> nodes

Constructor Detail

Builderback to summary
pack-priv Builder()

Method Detail

addEdgeback to summary
public void addEdge(T u, T v)
addNodeback to summary
public void addNode(T node)
addNodesback to summary
public void addNodes(Set<T> nodes)
buildback to summary
public Graph<T> build()
com.sun.tools.jdeps back to summary

pack-priv Class Graph.Edge<T>

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final T
u

pack-priv final T
v

Constructor Summary

AccessConstructor and Description
pack-priv
Edge(T u, T v)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object o)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

uback to summary
pack-priv final T u
vback to summary
pack-priv final T v

Constructor Detail

Edgeback to summary
pack-priv Edge(T u, T v)

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
com.sun.tools.jdeps back to summary

pack-priv Class Graph.TopoSorter<T>

extends Object
Class Inheritance

Topological sort

Field Summary

Modifier and TypeField and Description
pack-priv final Graph<T>
pack-priv final Deque<T>

Constructor Summary

AccessConstructor and Description
pack-priv
TopoSorter(Graph<T> graph)

Method Summary

Modifier and TypeMethod and Description
public void
ordered(Consumer<T> action)

public void
reverse(Consumer<T> action)

private void
sort()

private void
visit(T node, Set<T> visited, Set<T> done)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

graphback to summary
pack-priv final Graph<T> graph
resultback to summary
pack-priv final Deque<T> result

Constructor Detail

TopoSorterback to summary
pack-priv TopoSorter(Graph<T> graph)

Method Detail

orderedback to summary
public void ordered(Consumer<T> action)
reverseback to summary
public void reverse(Consumer<T> action)
sortback to summary
private void sort()
visitback to summary
private void visit(T node, Set<T> visited, Set<T> done)