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 doublegetCapacity(int uIndex, int vIndex)ShortcutgetCapacity(Node, Node).doublegetCapacity(String uId, String vId)ShortcutgetCapacity(Node, Node).doublegetCapacity(org.graphstream.graph.Node u, org.graphstream.graph.Node v)Get capacity of edge (u,v).StringgetCapacityAttribute()Get the key attribute from which capacities are loaded.doublegetFlow(int uIndex, int vIndex)Shortcut togetFlow(Node, Node).doublegetFlow(String uId, String vId)Shortcut togetFlow(Node, Node).doublegetFlow(org.graphstream.graph.Node u, org.graphstream.graph.Node v)Get flow value of edge (u,v).StringgetFlowSinkId()Get id of the sink.StringgetFlowSourceId()Get id of the source.doublegetMaximumFlow()Get maximum flow compute byAlgorithm.compute().voidinit(org.graphstream.graph.Graph graph)Initialization of the algorithm.voidinit(org.graphstream.graph.Graph g, String sourceId, String sinkId)Init the algorithm.voidsetAllCapacities(double value)voidsetCapacity(int uIndex, int vIndex, double capacity)Shortcut tosetCapacity(Node, Node, double).voidsetCapacity(String uId, String vId, double capacity)Shortcut tosetCapacity(Node, Node, double).voidsetCapacity(org.graphstream.graph.Node u, org.graphstream.graph.Node v, double capacity)Set capacity of (u,v).voidsetCapacityAttribute(String attribute)Set the key of the attribute from which capacities will be loaded.voidsetFlow(int uIndex, int vIndex, double flow)Shortcut tosetFlow(Node, Node, double).voidsetFlow(String uId, String vId, double flow)Shortcut tosetFlow(Node, Node, double).voidsetFlow(org.graphstream.graph.Node u, org.graphstream.graph.Node v, double flow)Set flow of edge (u,v).voidsetSinkId(String sinkId)voidsetSourceId(String sourceId)
-
Method Details
-
getFlowSourceId
Description copied from interface:FlowAlgorithmGet id of the source.- Specified by:
getFlowSourceIdin interfaceFlowAlgorithm- Returns:
- id of the source
-
getFlowSinkId
Description copied from interface:FlowAlgorithmGet id of the sink.- Specified by:
getFlowSinkIdin interfaceFlowAlgorithm- Returns:
- id of the sink
-
init
public void init(org.graphstream.graph.Graph graph)Description copied from interface:AlgorithmInitialization 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:FlowAlgorithmInit the algorithm. This method replaces theAlgorithm.init(Graph)method of Algorithm so users just have to call this new method.- Specified by:
initin 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:FlowAlgorithmGet maximum flow compute byAlgorithm.compute().- Specified by:
getMaximumFlowin 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:FlowAlgorithmGet flow value of edge (u,v).- Specified by:
getFlowin 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:FlowAlgorithmSet flow of edge (u,v).- Specified by:
setFlowin 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:FlowAlgorithmGet capacity of edge (u,v).- Specified by:
getCapacityin 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:FlowAlgorithmSet capacity of (u,v). Capacities should be set between calls toFlowAlgorithm.init(Graph, String, String)andAlgorithm.compute().- Specified by:
setCapacityin interfaceFlowAlgorithm- Parameters:
u- source nodev- target nodecapacity- new capacity of (u,v)
-
setCapacityAttribute
Description copied from interface:FlowAlgorithmSet 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:
setCapacityAttributein interfaceFlowAlgorithm- Parameters:
attribute- attribute name
-
getCapacityAttribute
Description copied from interface:FlowAlgorithmGet the key attribute from which capacities are loaded.- Specified by:
getCapacityAttributein interfaceFlowAlgorithm- Returns:
- key attribute of capacities
- See Also:
FlowAlgorithm.setCapacityAttribute(String)
-
setAllCapacities
public void setAllCapacities(double value)
-