what-the-bank/sources/com/google/common/graph/AbstractUndirectedNetworkCo...

73 lines
2.1 KiB
Java

package com.google.common.graph;
import com.google.common.base.Preconditions;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
/* loaded from: classes2.dex */
abstract class AbstractUndirectedNetworkConnections<N, E> implements NetworkConnections<N, E> {
protected final Map<E, N> incidentEdgeMap;
/* JADX INFO: Access modifiers changed from: protected */
public AbstractUndirectedNetworkConnections(Map<E, N> map) {
this.incidentEdgeMap = (Map) Preconditions.checkNotNull(map);
}
@Override // com.google.common.graph.NetworkConnections
public Set<N> predecessors() {
return adjacentNodes();
}
@Override // com.google.common.graph.NetworkConnections
public Set<N> successors() {
return adjacentNodes();
}
@Override // com.google.common.graph.NetworkConnections
public Set<E> incidentEdges() {
return Collections.unmodifiableSet(this.incidentEdgeMap.keySet());
}
@Override // com.google.common.graph.NetworkConnections
public Set<E> inEdges() {
return incidentEdges();
}
@Override // com.google.common.graph.NetworkConnections
public Set<E> outEdges() {
return incidentEdges();
}
@Override // com.google.common.graph.NetworkConnections
public N adjacentNode(E e) {
return (N) Preconditions.checkNotNull(this.incidentEdgeMap.get(e));
}
@Override // com.google.common.graph.NetworkConnections
public N removeInEdge(E e, boolean z) {
if (z) {
return null;
}
return removeOutEdge(e);
}
@Override // com.google.common.graph.NetworkConnections
public N removeOutEdge(E e) {
return (N) Preconditions.checkNotNull(this.incidentEdgeMap.remove(e));
}
@Override // com.google.common.graph.NetworkConnections
public void addInEdge(E e, N n, boolean z) {
if (z) {
return;
}
addOutEdge(e, n);
}
@Override // com.google.common.graph.NetworkConnections
public void addOutEdge(E e, N n) {
Preconditions.checkState(this.incidentEdgeMap.put(e, n) == null);
}
}