mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-26 17:12:31 -06:00
163 lines
7.1 KiB
Java
163 lines
7.1 KiB
Java
|
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<N> extends ForwardingGraph<N> {
|
||
|
private final BaseGraph<N> backingGraph;
|
||
|
|
||
|
@Override // com.google.common.graph.ForwardingGraph
|
||
|
BaseGraph<N> 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<N>) 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<N>) obj);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public ImmutableGraph(BaseGraph<N> baseGraph) {
|
||
|
this.backingGraph = baseGraph;
|
||
|
}
|
||
|
|
||
|
public static <N> ImmutableGraph<N> copyOf(Graph<N> graph) {
|
||
|
if (graph instanceof ImmutableGraph) {
|
||
|
return (ImmutableGraph) graph;
|
||
|
}
|
||
|
return new ImmutableGraph<>(new StandardValueGraph(GraphBuilder.from(graph), getNodeConnections(graph), graph.edges().size()));
|
||
|
}
|
||
|
|
||
|
@Deprecated
|
||
|
public static <N> ImmutableGraph<N> copyOf(ImmutableGraph<N> 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<N> incidentEdgeOrder() {
|
||
|
return ElementOrder.stable();
|
||
|
}
|
||
|
|
||
|
private static <N> ImmutableMap<N, GraphConnections<N, GraphConstants.Presence>> getNodeConnections(Graph<N> graph) {
|
||
|
ImmutableMap.Builder builder = ImmutableMap.builder();
|
||
|
for (N n : graph.nodes()) {
|
||
|
builder.put(n, connectionsOf(graph, n));
|
||
|
}
|
||
|
return builder.buildOrThrow();
|
||
|
}
|
||
|
|
||
|
private static <N> GraphConnections<N, GraphConstants.Presence> connectionsOf(Graph<N> 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<N> {
|
||
|
private final MutableGraph<N> mutableGraph;
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public Builder(GraphBuilder<N> graphBuilder) {
|
||
|
this.mutableGraph = graphBuilder.copy().incidentEdgeOrder(ElementOrder.stable()).build();
|
||
|
}
|
||
|
|
||
|
public Builder<N> addNode(N n) {
|
||
|
this.mutableGraph.addNode(n);
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
public Builder<N> putEdge(N n, N n2) {
|
||
|
this.mutableGraph.putEdge(n, n2);
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
public Builder<N> putEdge(EndpointPair<N> endpointPair) {
|
||
|
this.mutableGraph.putEdge(endpointPair);
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
public ImmutableGraph<N> build() {
|
||
|
return ImmutableGraph.copyOf(this.mutableGraph);
|
||
|
}
|
||
|
}
|
||
|
}
|