package com.google.common.graph; import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.graph.ImmutableNetwork; /* loaded from: classes2.dex */ public final class NetworkBuilder extends AbstractGraphBuilder { boolean allowsParallelEdges; ElementOrder edgeOrder; Optional expectedEdgeCount; /* JADX WARN: Multi-variable type inference failed */ private NetworkBuilder cast() { return this; } private NetworkBuilder(boolean z) { super(z); this.allowsParallelEdges = false; this.edgeOrder = ElementOrder.insertion(); this.expectedEdgeCount = Optional.absent(); } public static NetworkBuilder directed() { return new NetworkBuilder<>(true); } public static NetworkBuilder undirected() { return new NetworkBuilder<>(false); } public static NetworkBuilder from(Network network) { return new NetworkBuilder(network.isDirected()).allowsParallelEdges(network.allowsParallelEdges()).allowsSelfLoops(network.allowsSelfLoops()).nodeOrder(network.nodeOrder()).edgeOrder(network.edgeOrder()); } public final ImmutableNetwork.Builder immutable() { return new ImmutableNetwork.Builder<>(cast()); } public final NetworkBuilder allowsSelfLoops(boolean z) { this.allowsSelfLoops = z; return this; } public final NetworkBuilder expectedNodeCount(int i) { this.expectedNodeCount = Optional.of(Integer.valueOf(Graphs.checkNonNegative(i))); return this; } public final NetworkBuilder expectedEdgeCount(int i) { this.expectedEdgeCount = Optional.of(Integer.valueOf(Graphs.checkNonNegative(i))); return this; } public final NetworkBuilder nodeOrder(ElementOrder elementOrder) { NetworkBuilder networkBuilder = (NetworkBuilder) cast(); networkBuilder.nodeOrder = (ElementOrder) Preconditions.checkNotNull(elementOrder); return networkBuilder; } public final NetworkBuilder edgeOrder(ElementOrder elementOrder) { NetworkBuilder networkBuilder = (NetworkBuilder) cast(); networkBuilder.edgeOrder = (ElementOrder) Preconditions.checkNotNull(elementOrder); return networkBuilder; } public final MutableNetwork build() { return new StandardMutableNetwork(this); } public final NetworkBuilder allowsParallelEdges(boolean z) { this.allowsParallelEdges = z; return this; } }