I am tempted to do such kind of code, using jGraphT
/*
interface DirectedGraph<V,E> { ...}
interface WeightedGraph<V,E> { ...}
*/
public class SteinerTreeCalc {
public SteinerTreeCalc( < ??? implements DirectedGraph<V,E>, WeightedGraph<V,E> > graph ) {
......
}
}
I want to create a constructor that ask for an object implementing two interfaces.
Update :
In my goal, there are already chosen classes for Vertex and Edges (V and E), but thanks a lot to people who come up with :
public class SteinerTreeCalc <V, E, T extends DirectedGraph<V, E> & WeightedGraph<V, E>>
{
....
}
Yes, it's possible:
public class SteinerTreeCalc<T extends DirectedGraph<V,E> & WeightedGraph<V,E>> {
public SteinerTreeCalc(T graph) {
......
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With