In the following line
Graph<Number,Number> ig = Graphs.<Number,Number>synchronizedDirectedGraph(
new DirectedSparseMultigraph<Number,Number>());
could you please explain what Graphs.<Number,Number>synchronizedDirectedGraph means ? It looks like a call to a method Graphs.synchronizedDirectedGraph, but the template-like thingie after the dot puzzles me (at least due to my C++ background).
The problem is that Java is not very intelligent in the places it supports type inference.
For a method:
It infers the type
List<B>from the parameter type BBut if you need
List<A>you have to cast B or add the compiler hint:Part of the problem is that java generics are invariant so
List<B>is not a subtype ofList<A>.