package com.google.common.graph; import androidx.exifinterface.media.ExifInterface; import com.google.common.base.Function; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import com.google.errorprone.annotations.Immutable; import java.util.Map; import java.util.Set; @Immutable(containerOf = {"N", ExifInterface.LONGITUDE_EAST}) @ElementTypesAreNonnullByDefault /* loaded from: classes3.dex */ public final class ImmutableNetwork extends StandardNetwork { /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.graph.StandardNetwork, com.google.common.graph.Network public /* bridge */ /* synthetic */ Set adjacentNodes(Object obj) { return super.adjacentNodes(obj); } @Override // com.google.common.graph.StandardNetwork, com.google.common.graph.Network public /* bridge */ /* synthetic */ boolean allowsParallelEdges() { return super.allowsParallelEdges(); } @Override // com.google.common.graph.StandardNetwork, com.google.common.graph.Network public /* bridge */ /* synthetic */ boolean allowsSelfLoops() { return super.allowsSelfLoops(); } @Override // com.google.common.graph.StandardNetwork, com.google.common.graph.Network public /* bridge */ /* synthetic */ ElementOrder edgeOrder() { return super.edgeOrder(); } @Override // com.google.common.graph.StandardNetwork, com.google.common.graph.Network public /* bridge */ /* synthetic */ Set edges() { return super.edges(); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.graph.StandardNetwork, com.google.common.graph.AbstractNetwork, com.google.common.graph.Network public /* bridge */ /* synthetic */ Set edgesConnecting(Object obj, Object obj2) { return super.edgesConnecting(obj, obj2); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.graph.StandardNetwork, com.google.common.graph.Network public /* bridge */ /* synthetic */ Set inEdges(Object obj) { return super.inEdges(obj); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.graph.StandardNetwork, com.google.common.graph.Network public /* bridge */ /* synthetic */ Set incidentEdges(Object obj) { return super.incidentEdges(obj); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.graph.StandardNetwork, com.google.common.graph.Network public /* bridge */ /* synthetic */ EndpointPair incidentNodes(Object obj) { return super.incidentNodes(obj); } @Override // com.google.common.graph.StandardNetwork, com.google.common.graph.Network public /* bridge */ /* synthetic */ boolean isDirected() { return super.isDirected(); } @Override // com.google.common.graph.StandardNetwork, com.google.common.graph.Network public /* bridge */ /* synthetic */ ElementOrder nodeOrder() { return super.nodeOrder(); } @Override // com.google.common.graph.StandardNetwork, com.google.common.graph.Network public /* bridge */ /* synthetic */ Set nodes() { return super.nodes(); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.graph.StandardNetwork, com.google.common.graph.Network public /* bridge */ /* synthetic */ Set outEdges(Object obj) { return super.outEdges(obj); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.graph.StandardNetwork, com.google.common.graph.Network, com.google.common.graph.PredecessorsFunction, com.google.common.graph.Graph public /* bridge */ /* synthetic */ Set predecessors(Object obj) { return super.predecessors((ImmutableNetwork) obj); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.graph.StandardNetwork, com.google.common.graph.Network, com.google.common.graph.SuccessorsFunction, com.google.common.graph.Graph public /* bridge */ /* synthetic */ Set successors(Object obj) { return super.successors((ImmutableNetwork) obj); } private ImmutableNetwork(Network network) { super(NetworkBuilder.from(network), getNodeConnections(network), getEdgeToReferenceNode(network)); } public static ImmutableNetwork copyOf(Network network) { if (network instanceof ImmutableNetwork) { return (ImmutableNetwork) network; } return new ImmutableNetwork<>(network); } @Deprecated public static ImmutableNetwork copyOf(ImmutableNetwork immutableNetwork) { return (ImmutableNetwork) Preconditions.checkNotNull(immutableNetwork); } @Override // com.google.common.graph.AbstractNetwork, com.google.common.graph.Network public ImmutableGraph asGraph() { return new ImmutableGraph<>(super.asGraph()); } private static Map> getNodeConnections(Network network) { ImmutableMap.Builder builder = ImmutableMap.builder(); for (N n : network.nodes()) { builder.put(n, connectionsOf(network, n)); } return builder.buildOrThrow(); } private static Map getEdgeToReferenceNode(Network network) { ImmutableMap.Builder builder = ImmutableMap.builder(); for (E e : network.edges()) { builder.put(e, network.incidentNodes(e).nodeU()); } return builder.buildOrThrow(); } private static NetworkConnections connectionsOf(Network network, N n) { if (network.isDirected()) { Map asMap = Maps.asMap(network.inEdges(n), sourceNodeFn(network)); Map asMap2 = Maps.asMap(network.outEdges(n), targetNodeFn(network)); int size = network.edgesConnecting(n, n).size(); if (network.allowsParallelEdges()) { return DirectedMultiNetworkConnections.ofImmutable(asMap, asMap2, size); } return DirectedNetworkConnections.ofImmutable(asMap, asMap2, size); } Map asMap3 = Maps.asMap(network.incidentEdges(n), adjacentNodeFn(network, n)); if (network.allowsParallelEdges()) { return UndirectedMultiNetworkConnections.ofImmutable(asMap3); } return UndirectedNetworkConnections.ofImmutable(asMap3); } private static Function sourceNodeFn(final Network network) { return new Function() { // from class: com.google.common.graph.ImmutableNetwork$$ExternalSyntheticLambda0 @Override // com.google.common.base.Function public final Object apply(Object obj) { Object source; source = Network.this.incidentNodes(obj).source(); return source; } }; } private static Function targetNodeFn(final Network network) { return new Function() { // from class: com.google.common.graph.ImmutableNetwork$$ExternalSyntheticLambda1 @Override // com.google.common.base.Function public final Object apply(Object obj) { Object target; target = Network.this.incidentNodes(obj).target(); return target; } }; } private static Function adjacentNodeFn(final Network network, final N n) { return new Function() { // from class: com.google.common.graph.ImmutableNetwork$$ExternalSyntheticLambda2 @Override // com.google.common.base.Function public final Object apply(Object obj) { Object adjacentNode; adjacentNode = Network.this.incidentNodes(obj).adjacentNode(n); return adjacentNode; } }; } /* loaded from: classes3.dex */ public static class Builder { private final MutableNetwork mutableNetwork; /* JADX INFO: Access modifiers changed from: package-private */ public Builder(NetworkBuilder networkBuilder) { this.mutableNetwork = (MutableNetwork) networkBuilder.build(); } public Builder addNode(N n) { this.mutableNetwork.addNode(n); return this; } public Builder addEdge(N n, N n2, E e) { this.mutableNetwork.addEdge(n, n2, e); return this; } public Builder addEdge(EndpointPair endpointPair, E e) { this.mutableNetwork.addEdge(endpointPair, e); return this; } public ImmutableNetwork build() { return ImmutableNetwork.copyOf(this.mutableNetwork); } } }