
io.github.oliviercailloux.j_voting.graph.GraphView Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of j-voting Show documentation
Show all versions of j-voting Show documentation
General classes for dealing with social choice theory.
The newest version!
package io.github.oliviercailloux.j_voting.graph;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collections;
import java.util.Set;
import com.google.common.graph.EndpointPair;
import com.google.common.graph.Graph;
/**
* The sets accessible via this delegate are not currently editable
* (google/guava#3034), but this is not (currently) guaranteed by contract.
*/
public class GraphView extends ForwardingGraph {
public static Graph decorate(Graph delegate) {
return new GraphView<>(checkNotNull(delegate));
}
private GraphView(Graph delegate) {
this.delegate = delegate;
}
private Graph delegate;
@Override
protected Graph delegate() {
return delegate;
}
@Override
public Set nodes() {
return Collections.unmodifiableSet(super.nodes());
}
@Override
public Set adjacentNodes(N node) {
return Collections.unmodifiableSet(super.adjacentNodes(node));
}
@Override
public Set predecessors(N node) {
return Collections.unmodifiableSet(super.predecessors(node));
}
@Override
public Set successors(N node) {
return Collections.unmodifiableSet(super.successors(node));
}
@Override
public Set> edges() {
return Collections.unmodifiableSet(super.edges());
}
@Override
public Set> incidentEdges(N node) {
return Collections.unmodifiableSet(super.incidentEdges(node));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy