public class Arc extends Edge
Network
.
0.0f <= f(e) <= w(e)
.Network
predecessor, successor
Constructor and Description |
---|
Arc(Node predecessor,
Node successor)
Creates a new directed edge with a weight and a flow of
0.0f . |
Arc(Node predecessor,
Node successor,
float weight)
Creates a new directed edge with a flow of
0.0f . |
Arc(Node predecessor,
Node successor,
float weight,
float flow)
Creates a new directed edge.
|
Modifier and Type | Method and Description |
---|---|
void |
deserialize(Serializer s)
Deserializes (loads) the object data from the given serializer.
|
boolean |
equals(Arc arc)
Indicates whether the given arc equals this arc.
|
float |
getFlow()
Gets the flow value.
|
Node |
getPredecessor()
Gets the predecessor of the edge that means the vertex at which this is an outgoing edge.
|
Node |
getPredecessor(Vertex origin)
Gets the predecessor by an origin.
|
Node |
getSuccessor()
Gets the successor of the edge that means the vertex at which this is an incoming edge.
|
Node |
getSuccessor(Vertex origin)
Gets the successor by an origin.
|
void |
serialize(Serializer s)
Serializes (saves) the object data to the given serializer.
|
void |
setFlow(float flow)
Sets the flow value.
|
void |
setWeight(float weight)
Sets the weight of the edge.
|
java.lang.String |
toString()
Returns a string representation of the edge more precisely the weight of the vertex.
|
equals, equals, equalsIgnoreWeight, getGraph, getID, getIndex, getWeight, isDirected, isLoop, setDirected
public Arc(Node predecessor, Node successor) throws java.lang.IllegalArgumentException
0.0f
.predecessor
- the predecessor (the node at which this is an outgoing edge)successor
- the successor (the node at which this is an incoming edge)java.lang.IllegalArgumentException
- public Arc(Node predecessor, Node successor, float weight) throws java.lang.IllegalArgumentException
0.0f
.predecessor
- the predecessor (the node at which this is an outgoing edge)successor
- the successor (the node at which this is an incoming edge)weight
- the weight of the flow edgejava.lang.IllegalArgumentException
- public Arc(Node predecessor, Node successor, float weight, float flow) throws java.lang.IllegalArgumentException
predecessor
- the predecessor (the node at which this is an outgoing edge)successor
- the successor (the node at which this is an incoming edge)weight
- the weight of the flow edgeflow
- the flow valuejava.lang.IllegalArgumentException
- < 0
public Node getPredecessor()
Edge
Edge.getPredecessor(Vertex)
.getPredecessor
in class Edge
Edge.getPredecessor(Vertex)
public Node getPredecessor(Vertex origin)
Edge
Graph
regardless of
whether the edge is directed or not.
new Edge(v1, v2, 0, false)
. If you want to know the predecessor of v2 it is v1 but if
you want to know the predecessor of v1 by iterating over the incoming edges you cannot invoke
edge.getPredecessor()
because this is v1 itself. Therefore you have to invoke edge.getPredecessor(v1)
.
// iterate over the successors of v1 for(Vertex v1 : vertices) v1.getOutgoingEdge(i).getSuccessor(v1)... // iterate over the predecessors of v2 for(Vertex v2 : vertices) v2.getIncomingEdge(i).getPredecessor(v2)...
getPredecessor
in class Edge
origin
- the origin from which the predecessor is considerednull
if the vertex specified as the origin has nothing to do with this edgepublic Node getSuccessor()
Edge
Edge.getSuccessor(Vertex)
.getSuccessor
in class Edge
Edge.getSuccessor(Vertex)
public Node getSuccessor(Vertex origin)
Edge
Graph
regardless of
whether the edge is directed or not.
new Edge(v1, v2, 0, false)
. If you want to know the successor of v1 it is v2 but if
you want to know the successor of v2 by iterating over the outgoing edges you cannot invoke
edge.getSuccessor()
because this is v2 itself. Therefore you have to invoke edge.getSuccessor(v2)
.
// iterate over the successors of v1 for(Vertex v1 : vertices) v1.getOutgoingEdge(i).getSuccessor(v1)... // iterate over the predecessors of v1 for(Vertex v1 : vertices) v1.getIncomingEdge(i).getPredecessor(v1)...
getSuccessor
in class Edge
origin
- the origin from which the successor is considerednull
if the vertex specified as the origin has nothing to do with this edgepublic void setWeight(float weight) throws java.lang.IllegalArgumentException
public float getFlow()
public void setFlow(float flow) throws java.lang.IllegalArgumentException
flow
- the valuejava.lang.IllegalArgumentException
- < 0
public boolean equals(Arc arc)
arc
- the arctrue
if arc equals this arc otherwise false
public void serialize(Serializer s)
Serializable
serialize
in interface Serializable
serialize
in class Edge
s
- the serializer for the objectpublic void deserialize(Serializer s)
Serializable
deserialize
in interface Serializable
deserialize
in class Edge
s
- the serializer