
io.github.oliviercailloux.j_voting.preferences.classes.ImmutableAntiSymmetricPreferenceImpl 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.preferences.classes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.Preconditions;
import com.google.common.graph.EndpointPair;
import com.google.common.graph.Graph;
import io.github.oliviercailloux.j_voting.Alternative;
import io.github.oliviercailloux.j_voting.Voter;
import io.github.oliviercailloux.j_voting.preferences.ImmutableAntiSymmetricPreference;
public class ImmutableAntiSymmetricPreferenceImpl extends ImmutablePreferenceImpl
implements ImmutableAntiSymmetricPreference {
private static final Logger LOGGER = LoggerFactory.getLogger(ImmutableAntiSymmetricPreferenceImpl.class.getName());
/**
*
* @param voter not null
* @param graph not null
directed graph with ordered Alternatives
* @return new ImmutableAntiSymmetricPreference
*/
public static ImmutableAntiSymmetricPreferenceImpl asImmutableAntiSymmetricPreference(Voter voter,
Graph graph) {
Preconditions.checkNotNull(voter);
Preconditions.checkNotNull(graph);
return new ImmutableAntiSymmetricPreferenceImpl(voter, graph);
}
/**
* @param voter not null
* @param graph not null
directed graph with ordered Alternatives
*/
private ImmutableAntiSymmetricPreferenceImpl(Voter voter, Graph graph) {
super(voter, graph);
for (EndpointPair edge : super.asGraph().edges()) {
if (super.asGraph().hasEdgeConnecting(edge.nodeV(), edge.nodeU()) && !edge.nodeV().equals(edge.nodeU()))
throw new IllegalArgumentException("Two Alternatives can't be ranked ex-æquo");
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy