我很想使用jGraphT来编写这种类型的代码。
/*
interface DirectedGraph<V,E> { ...}
interface WeightedGraph<V,E> { ...}
*/
public class SteinerTreeCalc {
public SteinerTreeCalc( < ??? implements DirectedGraph<V,E>, WeightedGraph<V,E> > graph ) {
......
}
}
我想创建一个构造函数,要求传入实现两个接口的对象。
更新:
在我的目标中,已经选择了Vertex和Edges(V和E)的类,但非常感谢那些提出建议的人。
public class SteinerTreeCalc <V, E, T extends DirectedGraph<V, E> & WeightedGraph<V, E>>
{
....
}
DirectedGraph
又是WeightedGraph
的接口命名,这样你就可以将SteinerTreeCalc
的用户需要支持的所有合同条款放在一个地方吗? - Donal Fellows