Package org.graphstream.algorithm.flow
Class FlowAlgorithmBase
java.lang.Object
org.graphstream.algorithm.flow.FlowAlgorithmBase
- All Implemented Interfaces:
Algorithm
,FlowAlgorithm
- Direct Known Subclasses:
FordFulkersonAlgorithm
public abstract class FlowAlgorithmBase extends Object implements FlowAlgorithm
Base for flow algorithms. Provides features to handle capacities and flows.
-
Method Summary
Modifier and Type Method Description double
getCapacity(int uIndex, int vIndex)
ShortcutgetCapacity(Node, Node)
.double
getCapacity(String uId, String vId)
ShortcutgetCapacity(Node, Node)
.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(int uIndex, int vIndex)
Shortcut togetFlow(Node, Node)
.double
getFlow(String uId, String vId)
Shortcut togetFlow(Node, Node)
.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 graph)
Initialization of the algorithm.void
init(org.graphstream.graph.Graph g, String sourceId, String sinkId)
Init the algorithm.void
setAllCapacities(double value)
void
setCapacity(int uIndex, int vIndex, double capacity)
Shortcut tosetCapacity(Node, Node, double)
.void
setCapacity(String uId, String vId, double capacity)
Shortcut tosetCapacity(Node, Node, double)
.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(int uIndex, int vIndex, double flow)
Shortcut tosetFlow(Node, Node, double)
.void
setFlow(String uId, String vId, double flow)
Shortcut tosetFlow(Node, Node, double)
.void
setFlow(org.graphstream.graph.Node u, org.graphstream.graph.Node v, double flow)
Set flow of edge (u,v).void
setSinkId(String sinkId)
void
setSourceId(String sourceId)
-
Method Details
-
getFlowSourceId
Description copied from interface:FlowAlgorithm
Get id of the source.- Specified by:
getFlowSourceId
in interfaceFlowAlgorithm
- Returns:
- id of the source
-
getFlowSinkId
Description copied from interface:FlowAlgorithm
Get id of the sink.- Specified by:
getFlowSinkId
in interfaceFlowAlgorithm
- Returns:
- id of the sink
-
init
public void init(org.graphstream.graph.Graph graph)Description copied from interface:Algorithm
Initialization of the algorithm. This method has to be called before theAlgorithm.compute()
method to initialize or reset the algorithm according to the new given graph. -
init
Description copied from interface:FlowAlgorithm
Init the algorithm. This method replaces theAlgorithm.init(Graph)
method of Algorithm so users just have to call this new method.- Specified by:
init
in interfaceFlowAlgorithm
- Parameters:
g
- graph that should be used by the algorithmsourceId
- id of the source of the flowsinkId
- id of the sink of the flow
-
setSourceId
-
setSinkId
-
getMaximumFlow
public double getMaximumFlow()Description copied from interface:FlowAlgorithm
Get maximum flow compute byAlgorithm.compute()
.- Specified by:
getMaximumFlow
in interfaceFlowAlgorithm
- Returns:
- maximum flow
-
getFlow
public double getFlow(int uIndex, int vIndex)Shortcut togetFlow(Node, Node)
.- Parameters:
uIndex
- index of sourcevIndex
- index of target- Returns:
- flow of (u,v)
-
getFlow
Shortcut togetFlow(Node, Node)
.- Parameters:
uId
- id of sourcevId
- id of target- Returns:
- flow of (u,v)
-
getFlow
public double getFlow(org.graphstream.graph.Node u, org.graphstream.graph.Node v)Description copied from interface:FlowAlgorithm
Get flow value of edge (u,v).- Specified by:
getFlow
in interfaceFlowAlgorithm
- Parameters:
u
- source nodev
- target node- Returns:
- flow of (u,v)
-
setFlow
public void setFlow(int uIndex, int vIndex, double flow)Shortcut tosetFlow(Node, Node, double)
.- Parameters:
uIndex
- index of uvIndex
- index of vflow
- new float of (u,v)
-
setFlow
Shortcut tosetFlow(Node, Node, double)
.- Parameters:
uId
- id of uvId
- id of vflow
- new float of (u,v)
-
setFlow
public void setFlow(org.graphstream.graph.Node u, org.graphstream.graph.Node v, double flow)Description copied from interface:FlowAlgorithm
Set flow of edge (u,v).- Specified by:
setFlow
in interfaceFlowAlgorithm
- Parameters:
u
- source nodev
- target nodeflow
- new flow
-
getCapacity
public double getCapacity(int uIndex, int vIndex)ShortcutgetCapacity(Node, Node)
.- Parameters:
uIndex
- index of uvIndex
- index of v- Returns:
- capacity of (u,v).
-
getCapacity
ShortcutgetCapacity(Node, Node)
.- Parameters:
uId
- id of uvId
- id of v- Returns:
- capacity of (u,v).
-
getCapacity
public double getCapacity(org.graphstream.graph.Node u, org.graphstream.graph.Node v)Description copied from interface:FlowAlgorithm
Get capacity of edge (u,v).- Specified by:
getCapacity
in interfaceFlowAlgorithm
- Parameters:
u
- source nodev
- target node- Returns:
- capacity of (u,v)s
-
setCapacity
public void setCapacity(int uIndex, int vIndex, double capacity)Shortcut tosetCapacity(Node, Node, double)
.- Parameters:
uIndex
- index of uvIndex
- index of vcapacity
- new capacity of (u,v)
-
setCapacity
Shortcut tosetCapacity(Node, Node, double)
.- Parameters:
uId
- id of uvId
- id of vcapacity
- new capacity of (u,v)
-
setCapacity
public void setCapacity(org.graphstream.graph.Node u, org.graphstream.graph.Node v, double capacity)Description copied from interface:FlowAlgorithm
Set capacity of (u,v). Capacities should be set between calls toFlowAlgorithm.init(Graph, String, String)
andAlgorithm.compute()
.- Specified by:
setCapacity
in interfaceFlowAlgorithm
- Parameters:
u
- source nodev
- target nodecapacity
- new capacity of (u,v)
-
setCapacityAttribute
Description copied from interface:FlowAlgorithm
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()
.- Specified by:
setCapacityAttribute
in interfaceFlowAlgorithm
- Parameters:
attribute
- attribute name
-
getCapacityAttribute
Description copied from interface:FlowAlgorithm
Get the key attribute from which capacities are loaded.- Specified by:
getCapacityAttribute
in interfaceFlowAlgorithm
- Returns:
- key attribute of capacities
- See Also:
FlowAlgorithm.setCapacityAttribute(String)
-
setAllCapacities
public void setAllCapacities(double value)
-