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

pack-priv final Class DirectedGraphConnections<N, V>

extends Object
implements GraphConnections<N, V>
Class Inheritance
All Implemented Interfaces
com.google.common.graph.GraphConnections
Annotations
@ElementTypesAreNonnullByDefault
Type Parameters
<N>
Node parameter type
<V>
Value parameter type
Static Imports
com.google.common.base.Preconditions.checkArgument, .Preconditions.checkNotNull, .Preconditions.checkState, com.google.common.graph.GraphConstants.INNER_CAPACITY, .GraphConstants.INNER_LOAD_FACTOR, .Graphs.checkNonNegative, .Graphs.checkPositive

An implementation of GraphConnections for directed graphs.
Authors
James Sexton, Jens Nyman

Nested and Inner Type Summary

Modifier and TypeClass and Description
private abstract static class
DirectedGraphConnections.NodeConnection<N>

A value class representing single connection between the origin node and another node.

private static class
DirectedGraphConnections.PredAndSucc

A wrapper class to indicate a node is both a predecessor and successor while still providing the successor value.

Field Summary

Modifier and TypeField and Description
private final Map<N, Object>
private final List<DirectedGraphConnections.NodeConnection<N>>
orderedNodeConnections

All node connections in this graph, in edge insertion order.

private static final Object
private int
private int

Constructor Summary

AccessConstructor and Description
private
DirectedGraphConnections(Map<N, Object> adjacentNodeValues, List<DirectedGraphConnections.NodeConnection<N>> orderedNodeConnections, int predecessorCount, int successorCount)

Method Summary

Modifier and TypeMethod and Description
public void
addPredecessor(N node, V unused)

Implements com.google.common.graph.GraphConnections.addPredecessor.

Add node as a predecessor to the origin node.
public V
addSuccessor(N node, V value)

Implements com.google.common.graph.GraphConnections.addSuccessor.

Add node as a successor to the origin node.
public Set<N>
public Iterator<EndpointPair<N>>
incidentEdgeIterator(N
The node that this all of the connections in this class are connected to.
thisNode
)

Implements com.google.common.graph.GraphConnections.incidentEdgeIterator.

Returns an iterator over the incident edges.
private static boolean
private static boolean
pack-priv static <N, V> DirectedGraphConnections<N, V>
of(ElementOrder<N> incidentEdgeOrder)

pack-priv static <N, V> DirectedGraphConnections<N, V>
ofImmutable(N thisNode, Iterable<EndpointPair<N>> incidentEdges, Function<N, V> successorNodeToValueFn)

public Set<N>
public void
removePredecessor(N node)

Implements com.google.common.graph.GraphConnections.removePredecessor.

Remove node from the set of predecessors.
public V
removeSuccessor(Object node)

Implements com.google.common.graph.GraphConnections.removeSuccessor.

Remove node from the set of successors.
public Set<N>
public V
value(N node)

Implements com.google.common.graph.GraphConnections.value.

Returns the value associated with the edge connecting the origin node to node, or null if there is no such edge.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

adjacentNodeValuesback to summary
private final Map<N, Object> adjacentNodeValues
orderedNodeConnectionsback to summary
private final List<DirectedGraphConnections.NodeConnection<N>> orderedNodeConnections

All node connections in this graph, in edge insertion order.

Note

This field and adjacentNodeValues cannot be combined into a single LinkedHashMap because one target node may be mapped to both a predecessor and a successor. A LinkedHashMap combines two such edges into a single node-value pair, even though the edges may not have been inserted consecutively.

Annotations
@CheckForNull
PREDback to summary
private static final Object PRED
predecessorCountback to summary
private int predecessorCount
successorCountback to summary
private int successorCount

Constructor Detail

DirectedGraphConnectionsback to summary
private DirectedGraphConnections(Map<N, Object> adjacentNodeValues, List<DirectedGraphConnections.NodeConnection<N>> orderedNodeConnections, int predecessorCount, int successorCount)

Method Detail

addPredecessorback to summary
public void addPredecessor(N node, V unused)

Implements com.google.common.graph.GraphConnections.addPredecessor.

Doc from com.google.common.graph.GraphConnections.addPredecessor.

Add node as a predecessor to the origin node. In the case of an undirected graph, it also becomes a successor. Associates value with the edge connecting the two nodes.

Annotations
@Override
addSuccessorback to summary
public V addSuccessor(N node, V value)

Implements com.google.common.graph.GraphConnections.addSuccessor.

Doc from com.google.common.graph.GraphConnections.addSuccessor.

Add node as a successor to the origin node. In the case of an undirected graph, it also becomes a predecessor. Associates value with the edge connecting the two nodes. Returns the value previously associated with the edge connecting the two nodes.

Annotations
@SuppressWarnings:unchecked
@Override
@CheckForNull
adjacentNodesback to summary
public Set<N> adjacentNodes()

Implements com.google.common.graph.GraphConnections.adjacentNodes.

Annotations
@Override
incidentEdgeIteratorback to summary
public Iterator<EndpointPair<N>> incidentEdgeIterator(N thisNode)

Implements com.google.common.graph.GraphConnections.incidentEdgeIterator.

Doc from com.google.common.graph.GraphConnections.incidentEdgeIterator.

Returns an iterator over the incident edges.

Parameters
thisNode:N

The node that this all of the connections in this class are connected to.

Annotations
@Override
isPredecessorback to summary
private static boolean isPredecessor(Object value)
isSuccessorback to summary
private static boolean isSuccessor(Object value)
ofback to summary
pack-priv static <N, V> DirectedGraphConnections<N, V> of(ElementOrder<N> incidentEdgeOrder)
ofImmutableback to summary
pack-priv static <N, V> DirectedGraphConnections<N, V> ofImmutable(N thisNode, Iterable<EndpointPair<N>> incidentEdges, Function<N, V> successorNodeToValueFn)
predecessorsback to summary
public Set<N> predecessors()

Implements com.google.common.graph.GraphConnections.predecessors.

Annotations
@Override
removePredecessorback to summary
public void removePredecessor(N node)

Implements com.google.common.graph.GraphConnections.removePredecessor.

Doc from com.google.common.graph.GraphConnections.removePredecessor.

Remove node from the set of predecessors.

Annotations
@SuppressWarnings:unchecked
@Override
removeSuccessorback to summary
public V removeSuccessor(Object node)

Implements com.google.common.graph.GraphConnections.removeSuccessor.

Doc from com.google.common.graph.GraphConnections.removeSuccessor.

Remove node from the set of successors. Returns the value previously associated with the edge connecting the two nodes.

Annotations
@SuppressWarnings:unchecked
@Override
@CheckForNull
successorsback to summary
public Set<N> successors()

Implements com.google.common.graph.GraphConnections.successors.

Annotations
@Override
valueback to summary
public V value(N node)

Implements com.google.common.graph.GraphConnections.value.

Doc from com.google.common.graph.GraphConnections.value.

Returns the value associated with the edge connecting the origin node to node, or null if there is no such edge.

Annotations
@SuppressWarnings:unchecked
@Override
@CheckForNull
com.google.common.graph back to summary

private abstract Class DirectedGraphConnections.NodeConnection<N>

extends Object
Class Inheritance
  • java.lang.Object
  • com.google.common.graph.DirectedGraphConnections.NodeConnection
Known Direct Subclasses
com.google.common.graph.DirectedGraphConnections.NodeConnection.Pred, com.google.common.graph.DirectedGraphConnections.NodeConnection.Succ

A value class representing single connection between the origin node and another node.

There can be two types of connections (predecessor and successor), which is represented by the two implementations.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv static class

Field Summary

Modifier and TypeField and Description
pack-priv final N

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

nodeback to summary
pack-priv final N node

Constructor Detail

NodeConnectionback to summary
pack-priv NodeConnection(N node)
com.google.common.graph back to summary

pack-priv final Class DirectedGraphConnections.NodeConnection.Pred<N>

extends DirectedGraphConnections.NodeConnection<N>
Class Inheritance

Constructor Summary

AccessConstructor and Description
pack-priv
Pred(N node)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
that
)

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 the object.

Constructor Detail

Predback to summary
pack-priv Pred(N node)

Method Detail

equalsback to summary
public boolean equals(Object that)

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.

Parameters
that:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

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 the 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.
Returns:int

a hash code value for this object.

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

pack-priv final Class DirectedGraphConnections.NodeConnection.Succ<N>

extends DirectedGraphConnections.NodeConnection<N>
Class Inheritance

Constructor Summary

AccessConstructor and Description
pack-priv
Succ(N node)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
that
)

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 the object.

Constructor Detail

Succback to summary
pack-priv Succ(N node)

Method Detail

equalsback to summary
public boolean equals(Object that)

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.

Parameters
that:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

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 the 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.
Returns:int

a hash code value for this object.

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

private final Class DirectedGraphConnections.PredAndSucc

extends Object
Class Inheritance

A wrapper class to indicate a node is both a predecessor and successor while still providing the successor value.

Field Summary

Modifier and TypeField and Description
private final Object

Constructor Summary

AccessConstructor and Description
pack-priv
PredAndSucc(Object successorValue)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

successorValueback to summary
private final Object successorValue

Constructor Detail

PredAndSuccback to summary
pack-priv PredAndSucc(Object successorValue)