package com.google.common.graph; import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.graph.ElementOrder; import com.google.common.graph.ImmutableGraph; /* loaded from: classes2.dex */ public final class GraphBuilder extends AbstractGraphBuilder { /* JADX WARN: Multi-variable type inference failed */ private GraphBuilder cast() { return this; } private GraphBuilder(boolean z) { super(z); } public static GraphBuilder directed() { return new GraphBuilder<>(true); } public static GraphBuilder undirected() { return new GraphBuilder<>(false); } public static GraphBuilder from(Graph graph) { return new GraphBuilder(graph.isDirected()).allowsSelfLoops(graph.allowsSelfLoops()).nodeOrder(graph.nodeOrder()).incidentEdgeOrder(graph.incidentEdgeOrder()); } public final ImmutableGraph.Builder immutable() { return new ImmutableGraph.Builder<>(cast()); } public final GraphBuilder allowsSelfLoops(boolean z) { this.allowsSelfLoops = z; return this; } public final GraphBuilder expectedNodeCount(int i) { this.expectedNodeCount = Optional.of(Integer.valueOf(Graphs.checkNonNegative(i))); return this; } public final GraphBuilder nodeOrder(ElementOrder elementOrder) { GraphBuilder cast = cast(); cast.nodeOrder = (ElementOrder) Preconditions.checkNotNull(elementOrder); return cast; } public final GraphBuilder incidentEdgeOrder(ElementOrder elementOrder) { Preconditions.checkArgument(elementOrder.type() == ElementOrder.Type.UNORDERED || elementOrder.type() == ElementOrder.Type.STABLE, "The given elementOrder (%s) is unsupported. incidentEdgeOrder() only supports ElementOrder.unordered() and ElementOrder.stable().", elementOrder); GraphBuilder cast = cast(); cast.incidentEdgeOrder = (ElementOrder) Preconditions.checkNotNull(elementOrder); return cast; } public final MutableGraph build() { return new StandardMutableGraph(this); } /* JADX INFO: Access modifiers changed from: package-private */ public final GraphBuilder copy() { GraphBuilder graphBuilder = new GraphBuilder<>(this.directed); graphBuilder.allowsSelfLoops = this.allowsSelfLoops; graphBuilder.nodeOrder = this.nodeOrder; graphBuilder.expectedNodeCount = this.expectedNodeCount; graphBuilder.incidentEdgeOrder = this.incidentEdgeOrder; return graphBuilder; } }