Does this help you in creating custom edges ?
This particular example is drawn from the JGrapht internal documentation . Search for StoerWagnerMinimumCut algorithm inside the code base .
Here we go .
The idea here is to give some weights to the edges of the graph hence the need to manipulate the default weights.
final WeightedGraph<Set<V>, DefaultWeightedEdge> workingGraph;
....
workingGraph =
new SimpleWeightedGraph<Set<V>, DefaultWeightedEdge>(
DefaultWeightedEdge.class);
list = ....
workingGraph.addVertex(list);
....
// Lets manipulate the edge weights now
DefaultWeightedEdge eNew = workingGraph.getEdge(someSourcEdge, someTargetEdge);
if (eNew == null) {
eNew = workingGraph.addEdge(someSourcEdge, someTargetEdge);
workingGraph.setEdgeWeight(eNew, graph.getEdgeWeight(e));
} else {
workingGraph.setEdgeWeight(
eNew,
workingGraph.getEdgeWeight(eNew) + graph.getEdgeWeight(e));
I hope you can play around with the example and use it to create customized edges .
PS :
My answer my not be 100% correct but the idea is to point you to the correct direction in the docmentation :-)