Package org.graphstream.algorithm.flow
Interface FlowAlgorithm
- All Superinterfaces:
Algorithm
- All Known Implementing Classes:
EdmondsKarpAlgorithm
,FlowAlgorithmBase
,FordFulkersonAlgorithm
public interface FlowAlgorithm extends Algorithm
Defines algorithm used to compute maximum flow.
-
Method Summary
Modifier and Type Method Description double
getCapacity(org.graphstream.graph.Node u, org.graphstream.graph.Node v)
Get capacity of edge (u,v).String
getCapacityAttribute()
Get the key attribute from which capacities are loaded.double
getFlow(org.graphstream.graph.Node u, org.graphstream.graph.Node v)
Get flow value of edge (u,v).String
getFlowSinkId()
Get id of the sink.String
getFlowSourceId()
Get id of the source.double
getMaximumFlow()
Get maximum flow compute byAlgorithm.compute()
.void
init(org.graphstream.graph.Graph g, String sourceId, String sinkId)
Init the algorithm.void
setCapacity(org.graphstream.graph.Node u, org.graphstream.graph.Node v, double capacity)
Set capacity of (u,v).void
setCapacityAttribute(String attribute)
Set the key of the attribute from which capacities will be loaded.void
setFlow(org.graphstream.graph.Node u, org.graphstream.graph.Node v, double flow)
Set flow of edge (u,v).
-
Method Details
-
getFlow
double getFlow(org.graphstream.graph.Node u, org.graphstream.graph.Node v)Get flow value of edge (u,v).- Parameters:
u
- source nodev
- target node- Returns:
- flow of (u,v)
-
setFlow
void setFlow(org.graphstream.graph.Node u, org.graphstream.graph.Node v, double flow)Set flow of edge (u,v).- Parameters:
u
- source nodev
- target nodeflow
- new flow
-
getCapacity
double getCapacity(org.graphstream.graph.Node u, org.graphstream.graph.Node v)Get capacity of edge (u,v).- Parameters:
u
- source nodev
- target node- Returns:
- capacity of (u,v)s
-
setCapacity
void setCapacity(org.graphstream.graph.Node u, org.graphstream.graph.Node v, double capacity)Set capacity of (u,v). Capacities should be set between calls toinit(Graph, String, String)
andAlgorithm.compute()
.- Parameters:
u
- source nodev
- target nodecapacity
- new capacity of (u,v)
-
setCapacityAttribute
Set the key of the attribute from which capacities will be loaded. Attribute values of edge (u,v) should be an array of double where first element is the value of the capacity of (u,v) and second the capacity of (v,u). If there is only one value, the value of (v,u) will be zero. If no value is available, both capacities will be zero. If capacity attribute is null, you have to set capacities before callingAlgorithm.compute()
.- Parameters:
attribute
- attribute name
-
getCapacityAttribute
String getCapacityAttribute()Get the key attribute from which capacities are loaded.- Returns:
- key attribute of capacities
- See Also:
setCapacityAttribute(String)
-
getMaximumFlow
double getMaximumFlow()Get maximum flow compute byAlgorithm.compute()
.- Returns:
- maximum flow
-
getFlowSourceId
String getFlowSourceId()Get id of the source.- Returns:
- id of the source
-
getFlowSinkId
String getFlowSinkId()Get id of the sink.- Returns:
- id of the sink
-
init
Init the algorithm. This method replaces theAlgorithm.init(Graph)
method of Algorithm so users just have to call this new method.- Parameters:
g
- graph that should be used by the algorithmsourceId
- id of the source of the flowsinkId
- id of the sink of the flow
-