Coverage Summary for Class: UndirectedNetworkConnections (com.google.common.graph)
| Class | Class, % | Method, % | Line, % |
|---|---|---|---|
| UndirectedNetworkConnections | 0% (0/1) | 0% (0/5) | 0% (0/5) |
1 /* 2 * Copyright (C) 2016 The Guava Authors 3 * 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 at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * 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 and 14 * limitations under the License. 15 */ 16 17 package com.google.common.graph; 18 19 import static com.google.common.graph.GraphConstants.EXPECTED_DEGREE; 20 21 import com.google.common.collect.BiMap; 22 import com.google.common.collect.HashBiMap; 23 import com.google.common.collect.ImmutableBiMap; 24 import java.util.Collections; 25 import java.util.Map; 26 import java.util.Set; 27 28 /** 29 * An implementation of {@link NetworkConnections} for undirected networks. 30 * 31 * @author James Sexton 32 * @param <N> Node parameter type 33 * @param <E> Edge parameter type 34 */ 35 @ElementTypesAreNonnullByDefault 36 final class UndirectedNetworkConnections<N, E> extends AbstractUndirectedNetworkConnections<N, E> { 37 38 UndirectedNetworkConnections(Map<E, N> incidentEdgeMap) { 39 super(incidentEdgeMap); 40 } 41 42 static <N, E> UndirectedNetworkConnections<N, E> of() { 43 return new UndirectedNetworkConnections<>(HashBiMap.<E, N>create(EXPECTED_DEGREE)); 44 } 45 46 static <N, E> UndirectedNetworkConnections<N, E> ofImmutable(Map<E, N> incidentEdges) { 47 return new UndirectedNetworkConnections<>(ImmutableBiMap.copyOf(incidentEdges)); 48 } 49 50 @Override 51 public Set<N> adjacentNodes() { 52 return Collections.unmodifiableSet(((BiMap<E, N>) incidentEdgeMap).values()); 53 } 54 55 @Override 56 public Set<E> edgesConnecting(N node) { 57 return new EdgesConnecting<E>(((BiMap<E, N>) incidentEdgeMap).inverse(), node); 58 } 59 }