I assume that the class MyWeightedEdge already contains a method such as
public void setWeight(double weight)
If this is indeed the case, then what you need to do is:
Derive your own subclass from ListenableDirectedWeightedGraph (e.g., ListenableDirectedWeightedGraph). I would add both constructor versions, delegating to "super" to ensure compatibility with the original class.
Create the graph as in your question, but using the new class
ListenableDirectedWeightedGraph g =
new CustomListenableDirectedWeightedGraph(
MyWeightedEdge.class);
Override the method setEdgeWeight as follows:
public void setEdgeWeight(E e, double weight) {
super.setEdgeWeight(e, weight);
((MyWeightedEdge)e).setWeight(weight);
}
And, last but not least, override the toString method of the class MyWeightedEdge to return the label you want the edge to have (presumably including the weight, which is now available to it).
I hope this helps.