-
Notifications
You must be signed in to change notification settings - Fork 11
Max flow with weighted graphs #40
Comments
You should check out Adapting the code yourself shouldn't be too hard, maybe something along the lines of function maximum_flow(
flow_graph:: swg.AbstractSimpleWeightedGraph, # the input graph
source::Integer, # the source vertex
target::Integer, # the target vertex
algorithm::AbstractFlowAlgorithm = # keyword argument for algorithm
PushRelabelAlgorithm(),
restriction::Real = 0 # keyword argument for restriction max-flow
)
capacity_matrix = weights(flow_graph)'
if restriction > 0
return maximum_flow(flow_graph, source, target, min.(restriction, capacity_matrix), algorithm)
end
return maximum_flow(flow_graph, source, target, capacity_matrix, algorithm)
end |
@matbesancon would this be a welcome addition to |
Yes this can be added to this package, it's ok to make it depend on SimpleWeightedGraphs |
I've been working on a PR but it's not as straightforward as I said above. @EtienneInsa did you manage to make it work? |
Is there an advantage of writing a specalised methods for Also, we should make sure, that it is still possible to use a different capacity matrix with an If we have to add a dependency on SimpleWeightedGraphs.jl, we might think about using Requires.jl to lazy load that extra code when needed. |
Sounds like a good idea! However I'm not sure it is the only change necessary in |
(in case I can't debug it myself after a good night's sleep) |
indeed using
yes we can improve upon it |
It would be nice to specialize methods on weighted graphs, with weights representing the capacities. In a lot of situations, people who need flow algorithms work with weighted graphs. It also provide a sparse representation of the flow network. (without the need of an external sparse matrix).
(related : #9)
The text was updated successfully, but these errors were encountered: