1/*2* Copyright (C) 2016 The Guava Authors3*4* Licensed under the Apache License, Version 2.0 (the "License");5* you may not use this file except in compliance with the License.6* You may obtain a copy of the License at7*8* http://www.apache.org/licenses/LICENSE-2.09*10* Unless required by applicable law or agreed to in writing, software11* distributed under the License is distributed on an "AS IS" BASIS,12* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13* See the License for the specific language governing permissions and14* limitations under the License.15*/16 17packagecom.google.common.graph; 18 19importcom.google.errorprone.annotations.CanIgnoreReturnValue; 20importjava.util.Set; 21importjavax.annotation.Nullable; 22 23/**24* An interface for representing and manipulating an origin node's adjacent nodes and edge values in25* a {@link Graph}.26*27* @author James Sexton28* @param <N> Node parameter type29* @param <V> Value parameter type30*/31interfaceGraphConnections<N, V> { 32 33 Set<N> adjacentNodes(); 34 35 Set<N> predecessors(); 36 37 Set<N> successors(); 38 39/**40* Returns the value associated with the edge connecting the origin node to {@code node}, or null41* if there is no such edge.42*/43 @Nullable 44 V value(N node); 45 46/** Remove {@code node} from the set of predecessors. */47voidremovePredecessor(N node); 48 49/**50* Remove {@code node} from the set of successors. Returns the value previously associated with51* the edge connecting the two nodes.52*/53 @CanIgnoreReturnValue 54 V removeSuccessor(N node); 55 56/**57* Add {@code node} as a predecessor to the origin node. In the case of an undirected graph, it58* also becomes a successor. Associates {@code value} with the edge connecting the two nodes.59*/60voidaddPredecessor(N node, V value); 61 62/**63* Add {@code node} as a successor to the origin node. In the case of an undirected graph, it also64* becomes a predecessor. Associates {@code value} with the edge connecting the two nodes. Returns65* the value previously associated with the edge connecting the two nodes.66*/67 @CanIgnoreReturnValue 68 V addSuccessor(N node, V value); 69 }