APIdia Launch Partner
Top Description Inners Constructors Methods
com.sun.tools.javac.util

public Class GraphUtils

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Collection, .Properties

This is NOT part of any supported API. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public abstract static class
GraphUtils.AbstractNode<D, N extends GraphUtils.AbstractNode<D, N>>

This class is a basic abstract class for representing a node.

public static interface
GraphUtils.DependencyKind

Basic interface for defining various dependency kinds.

public static interface
GraphUtils.DottableNode<D, N extends GraphUtils.DottableNode<D, N>>

Optional interface for nodes supporting dot-based representation.

public static class
GraphUtils.DotVisitor<D, N extends GraphUtils.DottableNode<D, N>>

This visitor is used to dump the contents of a set of nodes of type DottableNode onto a string builder.

public static interface
GraphUtils.Node<D, N extends GraphUtils.Node<D, N>>

Common superinterfaces to all graph nodes.

pack-priv abstract static class
GraphUtils.NodeVisitor<D, N extends GraphUtils.Node<D, N>, A>

Visitor for graph nodes.

private static class
public abstract static class
GraphUtils.TarjanNode<D, N extends GraphUtils.TarjanNode<D, N>>

This class specializes Node, by adding elements that are required in order to perform Tarjan computation of strongly connected components.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static <D, N extends GraphUtils.TarjanNode<D, N>> List<? extends List<? extends N>>
tarjan(Iterable<? extends N> nodes)

Tarjan's algorithm to determine strongly connected components (SCCs) of a directed graph in linear time.

public static <D, N extends GraphUtils.DottableNode<D, N>> String
toDot(Collection<? extends N> nodes, String name, String header)

Debugging: dot representation of a set of connected nodes.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

GraphUtilsback to summary
public GraphUtils()

Method Detail

tarjanback to summary
public static <D, N extends GraphUtils.TarjanNode<D, N>> List<? extends List<? extends N>> tarjan(Iterable<? extends N> nodes)

Tarjan's algorithm to determine strongly connected components (SCCs) of a directed graph in linear time. Works on TarjanNode.

toDotback to summary
public static <D, N extends GraphUtils.DottableNode<D, N>> String toDot(Collection<? extends N> nodes, String name, String header)

Debugging: dot representation of a set of connected nodes. The resulting dot representation will use Node.toString to display node labels and Node.printDependency to display edge labels. The resulting representation is also customizable with a graph name and a header.

com.sun.tools.javac.util back to summary

public abstract Class GraphUtils.AbstractNode<D, N extends GraphUtils.AbstractNode<D, N>>

extends Object
implements GraphUtils.Node<D, N extends GraphUtils.AbstractNode<D, N>>
Class Inheritance
All Implemented Interfaces
com.sun.tools.javac.util.GraphUtils.Node
Known Direct Subclasses
com.sun.tools.javac.util.GraphUtils.TarjanNode, com.sun.tools.javac.util.Dependencies.GraphDependencies.Node

This class is a basic abstract class for representing a node. A node is associated with a given data.

Field Summary

Modifier and TypeField and Description
public final D

Constructor Summary

AccessConstructor and Description
public
AbstractNode(D data)

Method Summary

Modifier and TypeMethod and Description
public <A> void
accept(GraphUtils.NodeVisitor<D, N, A> visitor, A arg)

Implements com.sun.tools.javac.util.GraphUtils.Node.accept.

Visitor method.

public abstract Collection<? extends N>
getDependenciesByKind(GraphUtils.DependencyKind dk)

Get all dependencies of a given kind.

public abstract GraphUtils.DependencyKind[]
getSupportedDependencyKinds()

Get an array of the dependency kinds supported by this node.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

databack to summary
public final D data

Constructor Detail

AbstractNodeback to summary
public AbstractNode(D data)

Method Detail

acceptback to summary
public <A> void accept(GraphUtils.NodeVisitor<D, N, A> visitor, A arg)

Implements com.sun.tools.javac.util.GraphUtils.Node.accept.

Doc from com.sun.tools.javac.util.GraphUtils.Node.accept.

Visitor method.

Annotations
@SuppressWarnings:unchecked
getDependenciesByKindback to summary
public abstract Collection<? extends N> getDependenciesByKind(GraphUtils.DependencyKind dk)

Get all dependencies of a given kind.

getSupportedDependencyKindsback to summary
public abstract GraphUtils.DependencyKind[] getSupportedDependencyKinds()

Get an array of the dependency kinds supported by this node.

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.javac.util back to summary

public Interface GraphUtils.DependencyKind

Known Direct Implementers
com.sun.tools.javac.comp.Infer.DependencyKind, com.sun.tools.javac.util.Dependencies.CompletionCause

Basic interface for defining various dependency kinds.
com.sun.tools.javac.util back to summary

public Interface GraphUtils.DottableNode<D, N extends GraphUtils.DottableNode<D, N>>

extends GraphUtils.Node<D, N extends GraphUtils.DottableNode<D, N>>
Known Direct Implementers
com.sun.tools.javac.comp.Infer.GraphSolver.InferenceGraph.Node, com.sun.tools.javac.util.Dependencies.GraphDependencies.Node

Optional interface for nodes supporting dot-based representation.

Method Summary

Modifier and TypeMethod and Description
public Properties
dependencyAttributes(N to, GraphUtils.DependencyKind dk)

Retrieves the set of dot attributes associated with a given dependency.

public Properties
nodeAttributes()

Retrieves the set of dot attributes associated with the node.

Inherited from com.sun.tools.javac.util.GraphUtils.Node:
accept

Method Detail

dependencyAttributesback to summary
public Properties dependencyAttributes(N to, GraphUtils.DependencyKind dk)

Retrieves the set of dot attributes associated with a given dependency.

nodeAttributesback to summary
public Properties nodeAttributes()

Retrieves the set of dot attributes associated with the node.

com.sun.tools.javac.util back to summary

public Class GraphUtils.DotVisitor<D, N extends GraphUtils.DottableNode<D, N>>

extends GraphUtils.NodeVisitor<D, N extends GraphUtils.DottableNode<D, N>, StringBuilder>
Class Inheritance

This visitor is used to dump the contents of a set of nodes of type DottableNode onto a string builder.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected String
public void
visitDependency(GraphUtils.DependencyKind dk, N from, N to, StringBuilder buf)

Implements abstract com.sun.tools.javac.util.GraphUtils.NodeVisitor.visitDependency.

Visitor action for a dependency between 'from' and 'to' with given kind.

public void
visitNode(N node, StringBuilder buf)

Implements abstract com.sun.tools.javac.util.GraphUtils.NodeVisitor.visitNode.

Visitor action for nodes.

protected static String
Inherited from com.sun.tools.javac.util.GraphUtils.NodeVisitor:
visit

Constructor Detail

DotVisitorback to summary
public DotVisitor()

Method Detail

formatPropertiesback to summary
protected String formatProperties(Properties p)
visitDependencyback to summary
public void visitDependency(GraphUtils.DependencyKind dk, N from, N to, StringBuilder buf)

Implements abstract com.sun.tools.javac.util.GraphUtils.NodeVisitor.visitDependency.

Doc from com.sun.tools.javac.util.GraphUtils.NodeVisitor.visitDependency.

Visitor action for a dependency between 'from' and 'to' with given kind.

Annotations
@Override
visitNodeback to summary
public void visitNode(N node, StringBuilder buf)

Implements abstract com.sun.tools.javac.util.GraphUtils.NodeVisitor.visitNode.

Doc from com.sun.tools.javac.util.GraphUtils.NodeVisitor.visitNode.

Visitor action for nodes.

Annotations
@Override
wrapback to summary
protected static String wrap(String s)
com.sun.tools.javac.util back to summary

public Interface GraphUtils.Node<D, N extends GraphUtils.Node<D, N>>

Known Direct Subinterfaces
com.sun.tools.javac.util.GraphUtils.DottableNode
Known Direct Implementers
com.sun.tools.javac.util.GraphUtils.AbstractNode

Common superinterfaces to all graph nodes.

Method Summary

Modifier and TypeMethod and Description
public <A> void
accept(GraphUtils.NodeVisitor<D, N, A> visitor, A arg)

Visitor method.

Method Detail

acceptback to summary
public <A> void accept(GraphUtils.NodeVisitor<D, N, A> visitor, A arg)

Visitor method.

com.sun.tools.javac.util back to summary

pack-priv abstract Class GraphUtils.NodeVisitor<D, N extends GraphUtils.Node<D, N>, A>

extends Object
Class Inheritance
Known Direct Subclasses
com.sun.tools.javac.util.GraphUtils.DotVisitor, com.sun.tools.javac.util.Dependencies.GraphDependencies.PruneVisitor, com.sun.tools.javac.util.Dependencies.GraphDependencies.FilterVisitor

Visitor for graph nodes.

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
visit(Collection<? extends N> nodes, A arg)

Visitor entry point.

public abstract void
visitDependency(GraphUtils.DependencyKind dk, N from, N to, A arg)

Visitor action for a dependency between 'from' and 'to' with given kind.

public abstract void
visitNode(N node, A arg)

Visitor action for nodes.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

NodeVisitorback to summary
pack-priv NodeVisitor()

Method Detail

visitback to summary
public void visit(Collection<? extends N> nodes, A arg)

Visitor entry point.

visitDependencyback to summary
public abstract void visitDependency(GraphUtils.DependencyKind dk, N from, N to, A arg)

Visitor action for a dependency between 'from' and 'to' with given kind.

visitNodeback to summary
public abstract void visitNode(N node, A arg)

Visitor action for nodes.

com.sun.tools.javac.util back to summary

private Class GraphUtils.Tarjan<D, N extends GraphUtils.TarjanNode<D, N>>

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv int
index

Unique node identifier.

pack-priv ListBuffer<List<N>>
sccs

List of SCCs found so far.

pack-priv ListBuffer<N>
stack

Stack of all reachable nodes from given root.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private void
addSCC(N v)

private List<? extends List<? extends N>>
findSCC(Iterable<? extends N> nodes)

private void
findSCC(N v)

private void
visitNode(N n)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

indexback to summary
pack-priv int index

Unique node identifier.

sccsback to summary
pack-priv ListBuffer<List<N>> sccs

List of SCCs found so far.

stackback to summary
pack-priv ListBuffer<N> stack

Stack of all reachable nodes from given root.

Constructor Detail

Tarjanback to summary
private Tarjan()

Method Detail

addSCCback to summary
private void addSCC(N v)
findSCCback to summary
private List<? extends List<? extends N>> findSCC(Iterable<? extends N> nodes)
findSCCback to summary
private void findSCC(N v)
visitNodeback to summary
private void visitNode(N n)
com.sun.tools.javac.util back to summary

public abstract Class GraphUtils.TarjanNode<D, N extends GraphUtils.TarjanNode<D, N>>

extends GraphUtils.AbstractNode<D, N extends GraphUtils.TarjanNode<D, N>>
implements Comparable<N extends GraphUtils.TarjanNode<D, N>>
Class Inheritance
All Implemented Interfaces
java.lang.Comparable
Known Direct Subclasses
com.sun.tools.javac.comp.DeferredAttr.DeferredAttrContext.StuckNode, com.sun.tools.javac.comp.Infer.GraphSolver.InferenceGraph.Node

This class specializes Node, by adding elements that are required in order to perform Tarjan computation of strongly connected components.

Field Summary

Modifier and TypeField and Description
pack-priv boolean
pack-priv int
pack-priv int
Inherited from com.sun.tools.javac.util.GraphUtils.AbstractNode:
data

Constructor Summary

AccessConstructor and Description
public
TarjanNode(D data)

Method Summary

Modifier and TypeMethod and Description
public int
compareTo(N o)

Implements java.lang.Comparable.compareTo.

Compares this object with the specified object for order.

public abstract Iterable<? extends N>
Inherited from com.sun.tools.javac.util.GraphUtils.AbstractNode:
acceptgetDependenciesByKindgetSupportedDependencyKindstoString

Field Detail

activeback to summary
pack-priv boolean active
indexback to summary
pack-priv int index

Constructor Detail

TarjanNodeback to summary
public TarjanNode(D data)

Method Detail

compareToback to summary
public int compareTo(N o)

Implements java.lang.Comparable.compareTo.

Doc from java.lang.Comparable.compareTo.

Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

The implementor must ensure signum(x.compareTo(y)) == -signum(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception if and only if y.compareTo(x) throws an exception.)

The implementor must also ensure that the relation is transitive: (x.compareTo(y) > 0 && y.compareTo(z) > 0) implies x.compareTo(z) > 0.

Finally, the implementor must ensure that x.compareTo(y)==0 implies that signum(x.compareTo(z)) == signum(y.compareTo(z)), for all z.

Annotations
@Override
getAllDependenciesback to summary
public abstract Iterable<? extends N> getAllDependencies()