package com.google.common.graph; import com.google.common.base.Function; import com.google.common.base.Functions; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import com.google.common.graph.GraphConstants; import com.google.errorprone.annotations.Immutable; import java.util.Set; @Immutable(containerOf = {"N"}) @ElementTypesAreNonnullByDefault /* loaded from: classes3.dex */ public class ImmutableGraph extends ForwardingGraph { private final BaseGraph backingGraph; @Override // com.google.common.graph.ForwardingGraph BaseGraph delegate() { return this.backingGraph; } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.graph.ForwardingGraph, com.google.common.graph.BaseGraph, com.google.common.graph.Graph public /* bridge */ /* synthetic */ Set adjacentNodes(Object obj) { return super.adjacentNodes(obj); } @Override // com.google.common.graph.ForwardingGraph, com.google.common.graph.BaseGraph, com.google.common.graph.Graph public /* bridge */ /* synthetic */ boolean allowsSelfLoops() { return super.allowsSelfLoops(); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.graph.ForwardingGraph, com.google.common.graph.AbstractGraph, com.google.common.graph.AbstractBaseGraph, com.google.common.graph.BaseGraph public /* bridge */ /* synthetic */ int degree(Object obj) { return super.degree(obj); } @Override // com.google.common.graph.ForwardingGraph, com.google.common.graph.AbstractGraph, com.google.common.graph.AbstractBaseGraph, com.google.common.graph.BaseGraph public /* bridge */ /* synthetic */ boolean hasEdgeConnecting(EndpointPair endpointPair) { return super.hasEdgeConnecting(endpointPair); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.graph.ForwardingGraph, com.google.common.graph.AbstractGraph, com.google.common.graph.AbstractBaseGraph, com.google.common.graph.BaseGraph public /* bridge */ /* synthetic */ boolean hasEdgeConnecting(Object obj, Object obj2) { return super.hasEdgeConnecting(obj, obj2); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.graph.ForwardingGraph, com.google.common.graph.AbstractGraph, com.google.common.graph.AbstractBaseGraph, com.google.common.graph.BaseGraph public /* bridge */ /* synthetic */ int inDegree(Object obj) { return super.inDegree(obj); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.graph.ForwardingGraph, com.google.common.graph.AbstractGraph, com.google.common.graph.AbstractBaseGraph, com.google.common.graph.BaseGraph public /* bridge */ /* synthetic */ Set incidentEdges(Object obj) { return super.incidentEdges(obj); } @Override // com.google.common.graph.ForwardingGraph, com.google.common.graph.BaseGraph, com.google.common.graph.Graph public /* bridge */ /* synthetic */ boolean isDirected() { return super.isDirected(); } @Override // com.google.common.graph.ForwardingGraph, com.google.common.graph.BaseGraph, com.google.common.graph.Graph public /* bridge */ /* synthetic */ ElementOrder nodeOrder() { return super.nodeOrder(); } @Override // com.google.common.graph.ForwardingGraph, com.google.common.graph.BaseGraph, com.google.common.graph.Graph public /* bridge */ /* synthetic */ Set nodes() { return super.nodes(); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.graph.ForwardingGraph, com.google.common.graph.AbstractGraph, com.google.common.graph.AbstractBaseGraph, com.google.common.graph.BaseGraph public /* bridge */ /* synthetic */ int outDegree(Object obj) { return super.outDegree(obj); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.graph.ForwardingGraph, com.google.common.graph.BaseGraph, com.google.common.graph.PredecessorsFunction, com.google.common.graph.Graph public /* bridge */ /* synthetic */ Set predecessors(Object obj) { return super.predecessors((ImmutableGraph) obj); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.graph.ForwardingGraph, com.google.common.graph.BaseGraph, com.google.common.graph.SuccessorsFunction, com.google.common.graph.Graph public /* bridge */ /* synthetic */ Set successors(Object obj) { return super.successors((ImmutableGraph) obj); } /* JADX INFO: Access modifiers changed from: package-private */ public ImmutableGraph(BaseGraph baseGraph) { this.backingGraph = baseGraph; } public static ImmutableGraph copyOf(Graph graph) { if (graph instanceof ImmutableGraph) { return (ImmutableGraph) graph; } return new ImmutableGraph<>(new StandardValueGraph(GraphBuilder.from(graph), getNodeConnections(graph), graph.edges().size())); } @Deprecated public static ImmutableGraph copyOf(ImmutableGraph immutableGraph) { return (ImmutableGraph) Preconditions.checkNotNull(immutableGraph); } @Override // com.google.common.graph.ForwardingGraph, com.google.common.graph.AbstractGraph, com.google.common.graph.AbstractBaseGraph, com.google.common.graph.BaseGraph public ElementOrder incidentEdgeOrder() { return ElementOrder.stable(); } private static ImmutableMap> getNodeConnections(Graph graph) { ImmutableMap.Builder builder = ImmutableMap.builder(); for (N n : graph.nodes()) { builder.put(n, connectionsOf(graph, n)); } return builder.buildOrThrow(); } private static GraphConnections connectionsOf(Graph graph, N n) { Function constant = Functions.constant(GraphConstants.Presence.EDGE_EXISTS); if (graph.isDirected()) { return DirectedGraphConnections.ofImmutable(n, graph.incidentEdges(n), constant); } return UndirectedGraphConnections.ofImmutable(Maps.asMap(graph.adjacentNodes(n), constant)); } /* loaded from: classes3.dex */ public static class Builder { private final MutableGraph mutableGraph; /* JADX INFO: Access modifiers changed from: package-private */ public Builder(GraphBuilder graphBuilder) { this.mutableGraph = graphBuilder.copy().incidentEdgeOrder(ElementOrder.stable()).build(); } public Builder addNode(N n) { this.mutableGraph.addNode(n); return this; } public Builder putEdge(N n, N n2) { this.mutableGraph.putEdge(n, n2); return this; } public Builder putEdge(EndpointPair endpointPair) { this.mutableGraph.putEdge(endpointPair); return this; } public ImmutableGraph build() { return ImmutableGraph.copyOf(this.mutableGraph); } } }