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

public final Class ImmutableValueGraph<N, V>

extends StandardValueGraph<N, V>
Class Inheritance
Annotations
@Beta
@Immutable
containerOf:N, V
@SuppressWarnings:Immutable
@ElementTypesAreNonnullByDefault
Type Parameters
<N>
Node parameter type
<V>
Value parameter type
Static Imports
com.google.common.base.Preconditions.checkNotNull, java.util.Objects.requireNonNull

A ValueGraph whose elements and structural relationships will never change. Instances of this class may be obtained with copyOf(ValueGraph).

See the Guava User's Guide's discussion of the Immutable* types for more information on the properties and guarantees provided by this class.

Authors
James Sexton, Jens Nyman
Since
20.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
ImmutableValueGraph.Builder<N, V>

A builder for creating ImmutableValueGraph instances, especially static final graphs.

Field Summary

Inherited from com.google.common.graph.StandardValueGraph:
edgeCountnodeConnections

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public ImmutableGraph<N>
private static <N, V> GraphConnections<N, V>
connectionsOf(ValueGraph<N, V> graph, N node)

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

Returns an immutable copy of graph.

public static <N, V> ImmutableValueGraph<N, V>
copyOf(ImmutableValueGraph<N, V> graph)

Deprecated no need to use this
Simply returns its argument.
private static <N, V> ImmutableMap<N, GraphConnections<N, V>>
public ElementOrder<N>
Inherited from com.google.common.graph.StandardValueGraph:
adjacentNodesallowsSelfLoopscontainsNodeedgeCountedgeValueOrDefaultedgeValueOrDefaulthasEdgeConnectinghasEdgeConnectingincidentEdgesisDirectednodeOrdernodespredecessorssuccessors

Constructor Detail

ImmutableValueGraphback to summary
private ImmutableValueGraph(ValueGraph<N, V> graph)

Method Detail

asGraphback to summary
public ImmutableGraph<N> asGraph()

Overrides com.google.common.graph.AbstractValueGraph.asGraph.

Implements com.google.common.graph.ValueGraph.asGraph.

Doc from com.google.common.graph.ValueGraph.asGraph.

Returns a live view of this graph as a Graph. The resulting Graph will have an edge connecting node A to node B if this ValueGraph has an edge connecting A to B.

Annotations
@Override
connectionsOfback to summary
private static <N, V> GraphConnections<N, V> connectionsOf(ValueGraph<N, V> graph, N node)
copyOfback to summary
public static <N, V> ImmutableValueGraph<N, V> copyOf(ValueGraph<N, V> graph)

Returns an immutable copy of graph.

copyOfback to summary
public static <N, V> ImmutableValueGraph<N, V> copyOf(ImmutableValueGraph<N, V> graph)

Deprecated

no need to use this

Simply returns its argument.

Annotations
@Deprecated
getNodeConnectionsback to summary
private static <N, V> ImmutableMap<N, GraphConnections<N, V>> getNodeConnections(ValueGraph<N, V> graph)
incidentEdgeOrderback to summary
public ElementOrder<N> incidentEdgeOrder()

Overrides com.google.common.graph.AbstractBaseGraph.incidentEdgeOrder.

Implements com.google.common.graph.ValueGraph.incidentEdgeOrder, com.google.common.graph.BaseGraph.incidentEdgeOrder.

Doc from com.google.common.graph.ValueGraph.incidentEdgeOrder.

Returns an ElementOrder that specifies the order of iteration for the elements of edges(), adjacentNodes(Object), predecessors(Object), successors(Object) and incidentEdges(Object).

Annotations
@Override
com.google.common.graph back to summary

public Class ImmutableValueGraph.Builder<N, V>

extends Object
Class Inheritance

A builder for creating ImmutableValueGraph instances, especially static final graphs. Example:
static final ImmutableValueGraph<City, Distance> CITY_ROAD_DISTANCE_GRAPH =
    ValueGraphBuilder.undirected()
        .<City, Distance>immutable()
        .putEdgeValue(PARIS, BERLIN, kilometers(1060))
        .putEdgeValue(PARIS, BRUSSELS, kilometers(317))
        .putEdgeValue(BERLIN, BRUSSELS, kilometers(764))
        .addNode(REYKJAVIK)
        .build();

Builder instances can be reused; it is safe to call build multiple times to build multiple graphs in series. Each new graph contains all the elements of the ones created before it.

Since
28.0

Field Summary

Modifier and TypeField and Description
private final MutableValueGraph<N, V>

Constructor Summary

AccessConstructor and Description
pack-priv
Builder(ValueGraphBuilder<N, V> graphBuilder)

Method Summary

Modifier and TypeMethod and Description
public ImmutableValueGraph.Builder<N, V>

Returns:

this Builder object
addNode
(N node)

Adds node if it is not already present.

public ImmutableValueGraph<N, V>
build()

Returns a newly-created ImmutableValueGraph based on the contents of this Builder.

public ImmutableValueGraph.Builder<N, V>

Returns:

this Builder object
putEdgeValue
(N nodeU, N nodeV, V value)

Adds an edge connecting nodeU to nodeV if one is not already present, and sets a value for that edge to value (overwriting the existing value, if any).

public ImmutableValueGraph.Builder<N, V>

Returns:

this Builder object
putEdgeValue
(EndpointPair<N> endpoints, V value)

Adds an edge connecting endpoints if one is not already present, and sets a value for that edge to value (overwriting the existing value, if any).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

mutableValueGraphback to summary
private final MutableValueGraph<N, V> mutableValueGraph

Constructor Detail

Builderback to summary
pack-priv Builder(ValueGraphBuilder<N, V> graphBuilder)

Method Detail

addNodeback to summary
public ImmutableValueGraph.Builder<N, V> addNode(N node)

Adds node if it is not already present.

Nodes must be unique, just as Map keys must be. They must also be non-null.

Returns:ImmutableValueGraph.Builder<N, V>

this Builder object

Annotations
@CanIgnoreReturnValue
buildback to summary
public ImmutableValueGraph<N, V> build()

Returns a newly-created ImmutableValueGraph based on the contents of this Builder.

putEdgeValueback to summary
public ImmutableValueGraph.Builder<N, V> putEdgeValue(N nodeU, N nodeV, V value)

Adds an edge connecting nodeU to nodeV if one is not already present, and sets a value for that edge to value (overwriting the existing value, if any).

If the graph is directed, the resultant edge will be directed; otherwise, it will be undirected.

Values do not have to be unique. However, values must be non-null.

If nodeU and nodeV are not already present in this graph, this method will silently add nodeU and nodeV to the graph.

Returns:ImmutableValueGraph.Builder<N, V>

this Builder object

Annotations
@CanIgnoreReturnValue
Exceptions
IllegalArgumentException:
if the introduction of the edge would violate allowsSelfLoops()
putEdgeValueback to summary
public ImmutableValueGraph.Builder<N, V> putEdgeValue(EndpointPair<N> endpoints, V value)

Adds an edge connecting endpoints if one is not already present, and sets a value for that edge to value (overwriting the existing value, if any).

If the graph is directed, the resultant edge will be directed; otherwise, it will be undirected.

If this graph is directed, endpoints must be ordered.

Values do not have to be unique. However, values must be non-null.

If either or both endpoints are not already present in this graph, this method will silently add each missing endpoint to the graph.

Returns:ImmutableValueGraph.Builder<N, V>

this Builder object

Annotations
@CanIgnoreReturnValue
Exceptions
IllegalArgumentException:
  • if the introduction of the edge would violate allowsSelfLoops()
  • if the endpoints are unordered and the graph is directed