package com.google.common.graph; import com.google.common.base.Function; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterators; import com.google.common.graph.ElementOrder; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; /* loaded from: classes2.dex */ final class UndirectedGraphConnections implements GraphConnections { private final Map adjacentNodeValues; private UndirectedGraphConnections(Map map) { this.adjacentNodeValues = (Map) Preconditions.checkNotNull(map); } /* renamed from: com.google.common.graph.UndirectedGraphConnections$2, reason: invalid class name */ /* loaded from: classes2.dex */ static /* synthetic */ class AnonymousClass2 { static final int[] $SwitchMap$com$google$common$graph$ElementOrder$Type; static { int[] iArr = new int[ElementOrder.Type.values().length]; $SwitchMap$com$google$common$graph$ElementOrder$Type = iArr; try { iArr[ElementOrder.Type.UNORDERED.ordinal()] = 1; } catch (NoSuchFieldError unused) { } try { $SwitchMap$com$google$common$graph$ElementOrder$Type[ElementOrder.Type.STABLE.ordinal()] = 2; } catch (NoSuchFieldError unused2) { } } } /* JADX INFO: Access modifiers changed from: package-private */ public static UndirectedGraphConnections of(ElementOrder elementOrder) { int i = AnonymousClass2.$SwitchMap$com$google$common$graph$ElementOrder$Type[elementOrder.type().ordinal()]; if (i == 1) { return new UndirectedGraphConnections<>(new HashMap(2, 1.0f)); } if (i == 2) { return new UndirectedGraphConnections<>(new LinkedHashMap(2, 1.0f)); } throw new AssertionError(elementOrder.type()); } /* JADX INFO: Access modifiers changed from: package-private */ public static UndirectedGraphConnections ofImmutable(Map map) { return new UndirectedGraphConnections<>(ImmutableMap.copyOf((Map) map)); } @Override // com.google.common.graph.GraphConnections public final Set adjacentNodes() { return Collections.unmodifiableSet(this.adjacentNodeValues.keySet()); } @Override // com.google.common.graph.GraphConnections public final Set predecessors() { return adjacentNodes(); } @Override // com.google.common.graph.GraphConnections public final Set successors() { return adjacentNodes(); } @Override // com.google.common.graph.GraphConnections public final Iterator> incidentEdgeIterator(N n) { return Iterators.transform(this.adjacentNodeValues.keySet().iterator(), new Function>(this, n) { // from class: com.google.common.graph.UndirectedGraphConnections.1 final Object val$thisNode; { this.val$thisNode = n; } @Override // com.google.common.base.Function public /* bridge */ /* synthetic */ Object apply(Object obj) { return apply((AnonymousClass1) obj); } @Override // com.google.common.base.Function public EndpointPair apply(N n2) { return EndpointPair.unordered(this.val$thisNode, n2); } }); } @Override // com.google.common.graph.GraphConnections public final V value(N n) { return this.adjacentNodeValues.get(n); } @Override // com.google.common.graph.GraphConnections public final void removePredecessor(N n) { removeSuccessor(n); } @Override // com.google.common.graph.GraphConnections public final V removeSuccessor(N n) { return this.adjacentNodeValues.remove(n); } @Override // com.google.common.graph.GraphConnections public final void addPredecessor(N n, V v) { addSuccessor(n, v); } @Override // com.google.common.graph.GraphConnections public final V addSuccessor(N n, V v) { return this.adjacentNodeValues.put(n, v); } }