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.ImmutableValueGraph; /* loaded from: classes2.dex */ public final class ValueGraphBuilder extends AbstractGraphBuilder { /* JADX WARN: Multi-variable type inference failed */ private ValueGraphBuilder cast() { return this; } private ValueGraphBuilder(boolean z) { super(z); } public static ValueGraphBuilder directed() { return new ValueGraphBuilder<>(true); } public static ValueGraphBuilder undirected() { return new ValueGraphBuilder<>(false); } public static ValueGraphBuilder from(ValueGraph valueGraph) { return new ValueGraphBuilder(valueGraph.isDirected()).allowsSelfLoops(valueGraph.allowsSelfLoops()).nodeOrder(valueGraph.nodeOrder()).incidentEdgeOrder(valueGraph.incidentEdgeOrder()); } public final ImmutableValueGraph.Builder immutable() { return new ImmutableValueGraph.Builder<>(cast()); } public final ValueGraphBuilder allowsSelfLoops(boolean z) { this.allowsSelfLoops = z; return this; } public final ValueGraphBuilder expectedNodeCount(int i) { this.expectedNodeCount = Optional.of(Integer.valueOf(Graphs.checkNonNegative(i))); return this; } public final ValueGraphBuilder nodeOrder(ElementOrder elementOrder) { ValueGraphBuilder valueGraphBuilder = (ValueGraphBuilder) cast(); valueGraphBuilder.nodeOrder = (ElementOrder) Preconditions.checkNotNull(elementOrder); return valueGraphBuilder; } public final ValueGraphBuilder 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); ValueGraphBuilder valueGraphBuilder = (ValueGraphBuilder) cast(); valueGraphBuilder.incidentEdgeOrder = (ElementOrder) Preconditions.checkNotNull(elementOrder); return valueGraphBuilder; } public final MutableValueGraph build() { return new StandardMutableValueGraph(this); } /* JADX INFO: Access modifiers changed from: package-private */ public final ValueGraphBuilder copy() { ValueGraphBuilder valueGraphBuilder = new ValueGraphBuilder<>(this.directed); valueGraphBuilder.allowsSelfLoops = this.allowsSelfLoops; valueGraphBuilder.nodeOrder = this.nodeOrder; valueGraphBuilder.expectedNodeCount = this.expectedNodeCount; valueGraphBuilder.incidentEdgeOrder = this.incidentEdgeOrder; return valueGraphBuilder; } }