Top Description Inners Constructors Methods
com.google.common.graph

public final Class Graphs

extends Object
Class Inheritance
Annotations
@Beta
@ElementTypesAreNonnullByDefault
Static Imports
com.google.common.base.Preconditions.checkArgument, com.google.common.graph.GraphConstants.NODE_NOT_IN_GRAPH, java.util.Objects.requireNonNull

Static utility methods for Graph, ValueGraph, and Network instances.
Authors
James Sexton, Joshua O'Madadhain
Since
20.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum
Graphs.NodeVisitState

An enum representing the state of a node during DFS.

private static class
private static class
private static class

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static boolean
canTraverseWithoutReusingEdge(Graph<?> graph, Object nextNode, Object previousNode)

Determines whether an edge has already been used during traversal.

pack-priv static int
checkNonNegative(int value)

pack-priv static long
checkNonNegative(long value)

pack-priv static int
checkPositive(int value)

pack-priv static long
checkPositive(long value)

public static <N> MutableGraph<N>
copyOf(Graph<N> graph)

Creates a mutable copy of graph with the same nodes and edges.

public static <N, V> MutableValueGraph<N, V>
copyOf(ValueGraph<N, V> graph)

Creates a mutable copy of graph with the same nodes, edges, and edge values.

public static <N, E> MutableNetwork<N, E>
copyOf(Network<N, E> network)

Creates a mutable copy of network with the same nodes and edges.

public static <N> boolean
hasCycle(Graph<N> graph)

Returns true if graph has at least one cycle.

public static boolean
hasCycle(Network<?, ?> network)

Returns true if network has at least one cycle.

public static <N> MutableGraph<N>
inducedSubgraph(Graph<N> graph, Iterable<? extends N> nodes)

Returns the subgraph of graph induced by nodes.

public static <N, V> MutableValueGraph<N, V>
inducedSubgraph(ValueGraph<N, V> graph, Iterable<? extends N> nodes)

Returns the subgraph of graph induced by nodes.

public static <N, E> MutableNetwork<N, E>
inducedSubgraph(Network<N, E> network, Iterable<? extends N> nodes)

Returns the subgraph of network induced by nodes.

public static <N> Set<N>
reachableNodes(Graph<N> graph, N node)

Returns the set of nodes that are reachable from node.

private static <N> boolean
subgraphHasCycle(Graph<N> graph, Map<Object, Graphs.NodeVisitState> visitedNodes, N node, N previousNode)

Performs a traversal of the nodes reachable from node.

public static <N> Graph<N>
transitiveClosure(Graph<N> graph)

Returns the transitive closure of graph.

public static <N> Graph<N>
transpose(Graph<N> graph)

Returns a view of graph with the direction (if any) of every edge reversed.

public static <N, V> ValueGraph<N, V>
transpose(ValueGraph<N, V> graph)

Returns a view of graph with the direction (if any) of every edge reversed.

public static <N, E> Network<N, E>
transpose(Network<N, E> network)

Returns a view of network with the direction (if any) of every edge reversed.

pack-priv static <N> EndpointPair<N>
transpose(EndpointPair<N> endpoints)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait