com.happy3w.toolkits.sort.GraphNode Maven / Gradle / Ivy
package com.happy3w.toolkits.sort;
import lombok.Getter;
import lombok.Setter;
import java.util.HashSet;
import java.util.Set;
@Getter
@Setter
public class GraphNode {
private V value;
private Set needs;
private Set provides;
private Set> upstreamNodes = new HashSet<>();
private Set> downstreamNodes = new HashSet<>();
private int depth;
public GraphNode(V value, Set needs, Set provides) {
this.value = value;
this.needs = needs;
this.provides = provides;
ensureNoSelfCircle();
}
private void ensureNoSelfCircle() {
Set retains = new HashSet<>(needs);
retains.retainAll(provides);
if (!retains.isEmpty()) {
throw new IllegalArgumentException("There must be a circle with node:" + value);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy