Jung 라이브러리의 Hypergraph 구현을위한 인터페이스 및 클래스는 다음과 같습니다. 인터페이스 Hypergraph를 확장하여 ISimpleHypergraph 인터페이스를 생성하여 몇 가지 새로운 메서드를 포함시킨 다음 SetHypergraph 클래스를 확장하고 ISimpleHypergraph를 구현하여 SimpleHypergraph 클래스를 새로 만들었습니다.Java generics에서 사용자 정의 유형을 사용하는 방법
또한 id 및 weight 필드가있는 사용자 지정 SimpleV 및 SimpleH 형식을 만들었습니다. 이제 SimpleHypergraph에서 id 필드를 사용하는 몇 가지 방법을 어떻게 구현할 수 있습니까? SimpleHypergraph 내부 SimpleV 및 SimpleH는 인식 할 수 없습니다. 이 모든 제안이나 더 나은 방법?
Hypergraph 인터페이스와 SetHypergraph 인터페이스는 JUNG 라이브러리의 일부입니다.
public interface Hypergraph<V, H> {
// Other definitions
}
public interface ISimpleHypergraph<V, H> extends Hypergraph<V, H> {
H get(int id);
H get(Set<V> vSet);
// Other definitions
}
public class SetHypergraph<V, H> implements Hypergraph<V, H> {
protected Map<H, Set<V>> edges;
// Other fields
public SetHypergraph() {
edges = new HashMap<H, Set<V>>();
}
// Other methods
}
public class SimpleHypergraph<V, H> extends SetHypergraph<V, H> implements ISimpleHypergraph<V, H> {
public H get(int id) {
// How to use SimpleH.id and SimpleV.id here to get the
// searched Key entry from the Map<H, Set<V>> edges
}
public H get(Set<V> vSet) {
// How to use SimpleH.id and SimpleV.id here to get the
// searched Key entry from the Map<H, Set<V>> edges
}
}
public class SimpleV {
public int id;
public int weight;
public SimpleV(int id, int weight) {
this.id = id;
this.weight = weight;
}
// Other methods
}
public class SimpleH {
public int id;
public int weight;
public SimpleH(int id, int weight) {
this.id = id;
this.weight = weight;
}
// Other methods
}
일반 경계를 살펴보십시오. 또한 Java에는'implementation' 키워드가 없습니다. –
나는 경계를 정의하는 것을보고 있었지만 그것을 얻지는 못했습니다. 당신은 힌트를 줄 수 있습니까? – joarderm