mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-27 01:22:33 -06:00
75 lines
2.7 KiB
Java
75 lines
2.7 KiB
Java
|
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;
|
||
|
import com.google.errorprone.annotations.DoNotMock;
|
||
|
|
||
|
@DoNotMock
|
||
|
@ElementTypesAreNonnullByDefault
|
||
|
/* loaded from: classes3.dex */
|
||
|
public final class GraphBuilder<N> extends AbstractGraphBuilder<N> {
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
private <N1 extends N> GraphBuilder<N1> cast() {
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
private GraphBuilder(boolean z) {
|
||
|
super(z);
|
||
|
}
|
||
|
|
||
|
public static GraphBuilder<Object> directed() {
|
||
|
return new GraphBuilder<>(true);
|
||
|
}
|
||
|
|
||
|
public static GraphBuilder<Object> undirected() {
|
||
|
return new GraphBuilder<>(false);
|
||
|
}
|
||
|
|
||
|
public static <N> GraphBuilder<N> from(Graph<N> graph) {
|
||
|
return new GraphBuilder(graph.isDirected()).allowsSelfLoops(graph.allowsSelfLoops()).nodeOrder(graph.nodeOrder()).incidentEdgeOrder(graph.incidentEdgeOrder());
|
||
|
}
|
||
|
|
||
|
public <N1 extends N> ImmutableGraph.Builder<N1> immutable() {
|
||
|
return new ImmutableGraph.Builder<>(cast());
|
||
|
}
|
||
|
|
||
|
public GraphBuilder<N> allowsSelfLoops(boolean z) {
|
||
|
this.allowsSelfLoops = z;
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
public GraphBuilder<N> expectedNodeCount(int i) {
|
||
|
this.expectedNodeCount = Optional.of(Integer.valueOf(Graphs.checkNonNegative(i)));
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
public <N1 extends N> GraphBuilder<N1> nodeOrder(ElementOrder<N1> elementOrder) {
|
||
|
GraphBuilder<N1> cast = cast();
|
||
|
cast.nodeOrder = (ElementOrder) Preconditions.checkNotNull(elementOrder);
|
||
|
return cast;
|
||
|
}
|
||
|
|
||
|
public <N1 extends N> GraphBuilder<N1> incidentEdgeOrder(ElementOrder<N1> 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<N1> cast = cast();
|
||
|
cast.incidentEdgeOrder = (ElementOrder) Preconditions.checkNotNull(elementOrder);
|
||
|
return cast;
|
||
|
}
|
||
|
|
||
|
public <N1 extends N> MutableGraph<N1> build() {
|
||
|
return new StandardMutableGraph(this);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public GraphBuilder<N> copy() {
|
||
|
GraphBuilder<N> graphBuilder = new GraphBuilder<>(this.directed);
|
||
|
graphBuilder.allowsSelfLoops = this.allowsSelfLoops;
|
||
|
graphBuilder.nodeOrder = this.nodeOrder;
|
||
|
graphBuilder.expectedNodeCount = this.expectedNodeCount;
|
||
|
graphBuilder.incidentEdgeOrder = this.incidentEdgeOrder;
|
||
|
return graphBuilder;
|
||
|
}
|
||
|
}
|