Class StandardMutableNetwork<N,E>
- Type Parameters:
N- Node parameter typeE- Edge parameter type
- All Implemented Interfaces:
MutableNetwork<N,,E> Network<N,,E> PredecessorsFunction<N>,SuccessorsFunction<N>
MutableNetwork that supports both directed and undirected
graphs. Instances of this class should be constructed with NetworkBuilder.
Time complexities for mutation methods are all O(1) except for removeNode(N node),
which is in O(d_node) where d_node is the degree of node.
-
Field Summary
Fields inherited from class com.google.common.graph.StandardNetwork
edgeToReferenceNode, nodeConnections -
Constructor Summary
ConstructorsConstructorDescriptionStandardMutableNetwork(NetworkBuilder<? super N, ? super E> builder) Constructs a mutable graph with the properties specified inbuilder. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddEdge(EndpointPair<N> endpoints, E edge) Addsedgeconnectingendpoints.booleanAddsedgeconnectingnodeUtonodeV.booleanAddsnodeif it is not already present.private NetworkConnections<N,E> addNodeInternal(N node) Addsnodeto the graph and returns the associatedNetworkConnections.private NetworkConnections<N,E> booleanremoveEdge(E edge) Removesedgefrom this network, if it is present.booleanremoveNode(N node) Removesnodeif it is present; all edges incident tonodewill also be removed.Methods inherited from class com.google.common.graph.StandardNetwork
adjacentNodes, allowsParallelEdges, allowsSelfLoops, checkedConnections, checkedReferenceNode, containsEdge, containsNode, edgeOrder, edges, edgesConnecting, incidentEdges, incidentNodes, inEdges, isDirected, nodeOrder, nodes, outEdges, predecessors, successorsMethods inherited from class com.google.common.graph.AbstractNetwork
adjacentEdges, asGraph, degree, edgeConnecting, edgeConnecting, edgeConnectingOrNull, edgeConnectingOrNull, edgesConnecting, equals, hasEdgeConnecting, hasEdgeConnecting, hashCode, inDegree, isOrderingCompatible, outDegree, toString, validateEndpointsMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.google.common.graph.Network
adjacentEdges, adjacentNodes, allowsParallelEdges, allowsSelfLoops, asGraph, degree, edgeConnecting, edgeConnecting, edgeConnectingOrNull, edgeConnectingOrNull, edgeOrder, edges, edgesConnecting, edgesConnecting, equals, hasEdgeConnecting, hasEdgeConnecting, hashCode, incidentEdges, incidentNodes, inDegree, inEdges, isDirected, nodeOrder, nodes, outDegree, outEdges, predecessors, successors
-
Constructor Details
-
StandardMutableNetwork
StandardMutableNetwork(NetworkBuilder<? super N, ? super E> builder) Constructs a mutable graph with the properties specified inbuilder.
-
-
Method Details
-
addNode
Description copied from interface:MutableNetworkAddsnodeif it is not already present.Nodes must be unique, just as
Mapkeys must be. They must also be non-null.- Specified by:
addNodein interfaceMutableNetwork<N,E> - Returns:
trueif the network was modified as a result of this call
-
addNodeInternal
Addsnodeto the graph and returns the associatedNetworkConnections.- Throws:
IllegalStateException- ifnodeis already present
-
addEdge
Description copied from interface:MutableNetworkAddsedgeconnectingnodeUtonodeV.If the graph is directed,
edgewill be directed in this graph; otherwise, it will be undirected.edgemust be unique to this graph, just as aMapkey must be. It must also be non-null.If
nodeUandnodeVare not already present in this graph, this method will silentlyaddnodeUandnodeVto the graph.If
edgealready connectsnodeUtonodeV(in the specified order if this networkNetwork.isDirected(), else in any order), then this method will have no effect.- Specified by:
addEdgein interfaceMutableNetwork<N,E> - Returns:
trueif the network was modified as a result of this call
-
addEdge
Description copied from interface:MutableNetworkAddsedgeconnectingendpoints. In an undirected network,edgewill also connectnodeVtonodeU.If this graph is directed,
edgewill be directed in this graph; if it is undirected,edgewill be undirected in this graph.If this graph is directed,
endpointsmust be ordered.edgemust be unique to this graph, just as aMapkey must be. It must also be non-null.If either or both endpoints are not already present in this graph, this method will silently
addeach missing endpoint to the graph.If
edgealready connects an endpoint pair equal toendpoints, then this method will have no effect.- Specified by:
addEdgein interfaceMutableNetwork<N,E> - Returns:
trueif the network was modified as a result of this call
-
removeNode
Description copied from interface:MutableNetworkRemovesnodeif it is present; all edges incident tonodewill also be removed.- Specified by:
removeNodein interfaceMutableNetwork<N,E> - Returns:
trueif the network was modified as a result of this call
-
removeEdge
Description copied from interface:MutableNetworkRemovesedgefrom this network, if it is present.- Specified by:
removeEdgein interfaceMutableNetwork<N,E> - Returns:
trueif the network was modified as a result of this call
-
newConnections
-