Hi Gabe,
The best place to get answers to these kinds of questions is on
https://stackoverflow.com/ (use the tag *jgrapht*): yo u have a bigger
audience and more people will be able to answer, or benefit themselves from
the answers.
Short answers:
Option a: the get and set edgeWeight methods of a weighted graph simply
store an edge 'weight' as a double. You can freely interpret this weight.
If you want to interpret this weight as 'capacity' that's fine. If you want
to interpret it as 'cost' that's also fine. So in order to set the
capacities of the individual edges, all you have to do is invoke
setEdgeWeight on those edges with the desired capacity.
Option b: you could wrap your graph in a AsWeightedGraph class to define
custom weights, or to delegate the getEdgeWeight method to a 'function'.
Using AsWeightedGraph is particularly useful if your graph is essentially
unweighted and you want to make it weighted temporarily, or if you have a
graph where every edge has two sets of weights (e.g. cost and capacity).
Option c: create a graph with a custom edge implementation which extends
the DefaultWeightedEdge class (e.g. MyCustomeEdge extends
DefaultWeightedEdge). Then override the getEdgeWeight() method to return
your custom 'capacity' field instead.
These are just sketches of 3 simple solutions. If you could provide a short
code snippet of what you try to accomplish that would be easier.
Nevertheless, please put your question on stackoverflow.
br,
Joris Kinable
On Tue, Sep 28, 2021 at 7:36 AM Gábor Szegedi <gab...@gm...>
wrote:
> Dear Fellow JGraphT Users,
>
> I'm writing to you because I found something that I do not understand, and
> I need your help.
>
> So my findings are that the EdmondsKarpMFImpl
> <https://jgrapht.org/javadoc/org.jgrapht.core/org/jgrapht/alg/flow/EdmondsKarpMFImpl.html>
> is using the Edge weight as the capacity. But in that case how do you
> assign an upper bound to the capacity?
> Or how can I 'ask' the algorithm to use another field (which is
> implemented in my implementation of the DefaultWeightedEdge) as a capacity
> instead of the edge weight.
>
> I'm really hoping that someone could help me, it would require for my
> thesis.
>
> Cheers and Looking forward to hearing from you,
> Gabe
> _______________________________________________
> jgrapht-users mailing list
> jgr...@li...
> https://lists.sourceforge.net/lists/listinfo/jgrapht-users
>
|