Class AbstractGraph<N>
java.lang.Object
com.google.common.graph.AbstractGraph<N>
- Type Parameters:
N- Node parameter type
- All Implemented Interfaces:
Graph<N>, PredecessorsFunction<N>, SuccessorsFunction<N>
- Direct Known Subclasses:
ImmutableGraph
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionNetwork<N, EndpointPair<N>> intprotected longReturns the number of edges in this graph; used to calculate the size ofGraph.edges().Set<EndpointPair<N>> edges()An implementation ofBaseGraph.edges()defined in terms ofGraph.nodes()andSuccessorsFunction.successors(Object).final booleanReturnstrueiffobjectis aGraphthat has the same elements and the same structural relationships as those in this graph.booleanhasEdgeConnecting(EndpointPair<N> endpoints) booleanhasEdgeConnecting(N nodeU, N nodeV) final inthashCode()Returns the hash code for this graph.Set<EndpointPair<N>> incidentEdges(N node) intprotected final booleanisOrderingCompatible(EndpointPair<?> endpoints) Returnstrueiffendpoints' 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) inttoString()Returns a string representation of this graph.protected final voidvalidateEndpoints(EndpointPair<?> endpoints) ThrowsIllegalArgumentExceptionif the ordering ofendpointsis not compatible with the directionality of this graph.Methods inherited from interface Graph
adjacentNodes, allowsSelfLoops, degree, edges, hasEdgeConnecting, hasEdgeConnecting, incidentEdgeOrder, incidentEdges, inDegree, isDirected, nodeOrder, nodes, outDegree, predecessors, successorsModifier and TypeMethodDescriptionadjacentNodes(N node) Returns a live view of the nodes which have an incident edge in common withnodein this graph.booleanReturns true if this graph allows self-loops (edges that connect a node to itself).intReturns the count ofnode's incident edges, counting self-loops twice (equivalently, the number of times an edge touchesnode).Set<EndpointPair<N>> edges()Returns all edges in this graph.booleanhasEdgeConnecting(EndpointPair<N> endpoints) Returns true if there is an edge that directly connectsendpoints(in the order, if any, specified byendpoints).booleanhasEdgeConnecting(N nodeU, N nodeV) Returns true if there is an edge that directly connectsnodeUtonodeV.Returns anElementOrderthat specifies the order of iteration for the elements ofGraph.edges(),Graph.adjacentNodes(Object),Graph.predecessors(Object),Graph.successors(Object)andGraph.incidentEdges(Object).Set<EndpointPair<N>> incidentEdges(N node) Returns a live view of the edges in this graph whose endpoints includenode.intReturns the count ofnode's incoming edges (equal topredecessors(node).size()) in a directed graph.booleanReturns true if the edges in this graph are directed.Returns the order of iteration for the elements ofGraph.nodes().nodes()Returns all nodes in this graph, in the order specified byGraph.nodeOrder().intReturns the count ofnode's outgoing edges (equal tosuccessors(node).size()) in a directed graph.predecessors(N node) Returns a live view of all nodes in this graph adjacent tonodewhich can be reached by traversingnode's incoming edges against the direction (if any) of the edge.successors(N node) Returns a live view of all nodes in this graph adjacent tonodewhich can be reached by traversingnode's outgoing edges in the direction (if any) of the edge.
-
Constructor Details
-
AbstractGraph
public AbstractGraph()Constructor for use by subclasses.
-
-
Method Details
-
equals
Description copied from interface:GraphReturnstrueiffobjectis aGraphthat has the same elements and the same structural relationships as those in this graph.Thus, two graphs A and B are equal if all of the following are true:
- A and B have equal
directedness. - A and B have equal
node sets. - A and B have equal
edge sets.
Graph properties besides
directednessdo not affect equality. For example, two graphs may be considered equal even if one allows self-loops and the other doesn't. Additionally, the order in which nodes or edges are added to the graph, and the order in which they are iterated over, are irrelevant.A reference implementation of this is provided by
equals(Object). - A and B have equal
-
hashCode
public final int hashCode()Description copied from interface:GraphReturns the hash code for this graph. The hash code of a graph is defined as the hash code of the set returned byGraph.edges().A reference implementation of this is provided by
hashCode(). -
toString
-
edgeCount
protected long edgeCount()Returns the number of edges in this graph; used to calculate the size ofGraph.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. -
edges
An implementation ofBaseGraph.edges()defined in terms ofGraph.nodes()andSuccessorsFunction.successors(Object). -
incidentEdgeOrder
-
incidentEdges
-
degree
-
inDegree
-
outDegree
-
hasEdgeConnecting
-
hasEdgeConnecting
-
asNetwork
-
validateEndpoints
ThrowsIllegalArgumentExceptionif the ordering ofendpointsis not compatible with the directionality of this graph. -
isOrderingCompatible
Returnstrueiffendpoints' ordering is compatible with the directionality of this graph. -
nodeInvalidatableSet
-
nodePairInvalidatableSet
-