Top Description Constructors Methods
com.google.common.graph

pack-priv abstract Class AbstractBaseGraph<N>

extends Object
implements BaseGraph<N>
Class Inheritance
All Implemented Interfaces
com.google.common.graph.BaseGraph, com.google.common.graph.PredecessorsFunction, com.google.common.graph.SuccessorsFunction
Known Direct Subclasses
com.google.common.graph.AbstractGraph, com.google.common.graph.AbstractValueGraph
Annotations
@ElementTypesAreNonnullByDefault
Type Parameters
<N>
Node parameter type
Static Imports
com.google.common.base.Preconditions.checkArgument, .Preconditions.checkNotNull, .Preconditions.checkState, com.google.common.graph.GraphConstants.ENDPOINTS_MISMATCH, .GraphConstants.NODE_PAIR_REMOVED_FROM_GRAPH, .GraphConstants.NODE_REMOVED_FROM_GRAPH

This class provides a skeletal implementation of BaseGraph.

The methods implemented in this class should not be overridden unless the subclass admits a more efficient implementation.

Author
James Sexton

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public int
degree(N node)

Implements com.google.common.graph.BaseGraph.degree.

Returns the count of node's incident edges, counting self-loops twice (equivalently, the number of times an edge touches node).
protected long
edgeCount()

Returns the number of edges in this graph; used to calculate the size of Graph#edges().

public Set<EndpointPair<N>>
edges()

Implements com.google.common.graph.BaseGraph.edges.

An implementation of BaseGraph#edges() defined in terms of Graph#nodes() and successors(Object).
public boolean
hasEdgeConnecting(N nodeU, N nodeV)

Implements com.google.common.graph.BaseGraph.hasEdgeConnecting.

Returns true if there is an edge that directly connects nodeU to nodeV.
public boolean
hasEdgeConnecting(EndpointPair<N> endpoints)

Implements com.google.common.graph.BaseGraph.hasEdgeConnecting.

Returns true if there is an edge that directly connects endpoints (in the order, if any, specified by endpoints).
public ElementOrder<N>
public Set<EndpointPair<N>>
incidentEdges(N node)

Implements com.google.common.graph.BaseGraph.incidentEdges.

Returns a live view of the edges in this graph whose endpoints include node.
public int
inDegree(N node)

Implements com.google.common.graph.BaseGraph.inDegree.

Returns the count of node's incoming edges (equal to predecessors(node).size()) in a directed graph.
protected final boolean
isOrderingCompatible(EndpointPair<?> endpoints)

Returns true iff endpoints' ordering is compatible with the directionality of this graph.

protected final <T> Set<T>
nodeInvalidatableSet(Set<T> set, N node)

protected final <T> Set<T>
nodePairInvalidatableSet(Set<T> set, N nodeU, N nodeV)

public int
outDegree(N node)

Implements com.google.common.graph.BaseGraph.outDegree.

Returns the count of node's outgoing edges (equal to successors(node).size()) in a directed graph.
protected final void
validateEndpoints(EndpointPair<?> endpoints)

Throws IllegalArgumentException if the ordering of endpoints is not compatible with the directionality of this graph.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

AbstractBaseGraphback to summary
pack-priv AbstractBaseGraph()

Method Detail

degreeback to summary
public int degree(N node)

Implements com.google.common.graph.BaseGraph.degree.

Doc from com.google.common.graph.BaseGraph.degree.

Returns the count of node's incident edges, counting self-loops twice (equivalently, the number of times an edge touches node).

For directed graphs, this is equal to inDegree(node) + outDegree(node).

For undirected graphs, this is equal to incidentEdges(node).size() + (number of self-loops incident to node).

If the count is greater than Integer.MAX_VALUE, returns Integer.MAX_VALUE.

Annotations
@Override
edgeCountback to summary
protected long edgeCount()

Returns the number of edges in this graph; used to calculate the size of Graph#edges(). This implementation requires O(|N|) time. Classes extending this one may manually keep track of the number of edges as the graph is updated, and override this method for better performance.

edgesback to summary
public Set<EndpointPair<N>> edges()

Implements com.google.common.graph.BaseGraph.edges.

An implementation of BaseGraph#edges() defined in terms of Graph#nodes() and successors(Object).

Annotations
@Override
hasEdgeConnectingback to summary
public boolean hasEdgeConnecting(N nodeU, N nodeV)

Implements com.google.common.graph.BaseGraph.hasEdgeConnecting.

Doc from com.google.common.graph.BaseGraph.hasEdgeConnecting.

Returns true if there is an edge that directly connects nodeU to nodeV. This is equivalent to nodes().contains(nodeU) && successors(nodeU).contains(nodeV).

In an undirected graph, this is equal to hasEdgeConnecting(nodeV, nodeU).

Annotations
@Override
hasEdgeConnectingback to summary
public boolean hasEdgeConnecting(EndpointPair<N> endpoints)

Implements com.google.common.graph.BaseGraph.hasEdgeConnecting.

Doc from com.google.common.graph.BaseGraph.hasEdgeConnecting.

Returns true if there is an edge that directly connects endpoints (in the order, if any, specified by endpoints). This is equivalent to edges().contains(endpoints).

Unlike the other EndpointPair-accepting methods, this method does not throw if the endpoints are unordered; it simply returns false. This is for consistency with the behavior of Collection#contains(Object) (which does not generally throw if the object cannot be present in the collection), and the desire to have this method's behavior be compatible with edges().contains(endpoints).

Annotations
@Override
incidentEdgeOrderback to summary
public ElementOrder<N> incidentEdgeOrder()

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

Doc from com.google.common.graph.BaseGraph.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
incidentEdgesback to summary
public Set<EndpointPair<N>> incidentEdges(N node)

Implements com.google.common.graph.BaseGraph.incidentEdges.

Doc from com.google.common.graph.BaseGraph.incidentEdges.

Returns a live view of the edges in this graph whose endpoints include node.

This is equal to the union of incoming and outgoing edges.

If node is removed from the graph after this method is called, the Set view returned by this method will be invalidated, and will throw IllegalStateException if it is accessed in any way, with the following exceptions:

  • view.equals(view) evaluates to true (but any other `equals()` expression involving view will throw)
  • hashCode() does not throw
  • if node is re-added to the graph after having been removed, view's behavior is undefined
Annotations
@Override
inDegreeback to summary
public int inDegree(N node)

Implements com.google.common.graph.BaseGraph.inDegree.

Doc from com.google.common.graph.BaseGraph.inDegree.

Returns the count of node's incoming edges (equal to predecessors(node).size()) in a directed graph. In an undirected graph, returns the degree(Object).

If the count is greater than Integer.MAX_VALUE, returns Integer.MAX_VALUE.

Annotations
@Override
isOrderingCompatibleback to summary
protected final boolean isOrderingCompatible(EndpointPair<?> endpoints)

Returns true iff endpoints' ordering is compatible with the directionality of this graph.

nodeInvalidatableSetback to summary
protected final <T> Set<T> nodeInvalidatableSet(Set<T> set, N node)
nodePairInvalidatableSetback to summary
protected final <T> Set<T> nodePairInvalidatableSet(Set<T> set, N nodeU, N nodeV)
outDegreeback to summary
public int outDegree(N node)

Implements com.google.common.graph.BaseGraph.outDegree.

Doc from com.google.common.graph.BaseGraph.outDegree.

Returns the count of node's outgoing edges (equal to successors(node).size()) in a directed graph. In an undirected graph, returns the degree(Object).

If the count is greater than Integer.MAX_VALUE, returns Integer.MAX_VALUE.

Annotations
@Override
validateEndpointsback to summary
protected final void validateEndpoints(EndpointPair<?> endpoints)

Throws IllegalArgumentException if the ordering of endpoints is not compatible with the directionality of this graph.