public class TLcdNumericGraph extends Object implements ILcdGraph<Long,Long>
long
primitives
(or corresponding Long
objects wherever an Object
is required).
The mapping from partition/node/edge to numeric identifier is done in the
TLcdNumericGraphEncoder
during the export. Users of the numeric graph API should not rely
on the rules that are used to map a graph onto a numeric graph.
null
.
addNode
: adds a new node to the graph. A unique numeric identifier is created for the node and
returned.addEdge
: adds a new edge to the graph. A unique numeric identifier is created for the edge and
returned.updateEdgeValue
: updates the values of an edge in the graphaddEdge
or updateEdgeValue
method is called, the distance tables of
all partitions that are involved in the change will be discarded (the distance table provider
will return null
for these partitions). The next time a distance table is needed, the
distance table provider will lazily update all necessary distance tables (this can cause a
noticeable delay).
Removing edges is not possible. If an edge need to be disabled, this can be done so by setting
its edge value to Double.POSITIVE_INFINITY
.Modifier and Type | Method and Description |
---|---|
void |
addGraphListener(ILcdGraphListener<Long,Long> aGraphListener)
Registers the given
ILcdGraphListener with this graph. |
boolean |
containsEdge(Long aEdge)
Returns true if
aEdge is contained in this graph, false otherwise. |
boolean |
containsNode(Long aNode)
Returns true if
aNode is part of this graph, false otherwise. |
Long |
createAndAddEdge(Long aStartNode,
Long aEndNode,
int aFireEventMode)
Creates and adds a new edge to this graph.
|
Long |
createAndAddNode(int aFireEventMode)
Creates and adds a new node to this graph.
|
void |
fireCollectedGraphChanges()
Fires all the collected graph changes, i.e., all graph events that have been
generated using the ILcdFireEventMode.FIRE_LATER mode, after the
previous call to
fireCollectedGraphChanges() . |
Enumeration<Long> |
getEdges()
Returns an Enumeration containing all edges in this graph.
|
Enumeration<Long> |
getEdges(Long aNode)
Returns an Enumeration containing all edges connected to the given node.
|
ILcdEdgeValueFunction<Long,Long> |
getEdgeValueFunction()
Returns the edge value function describing the weights of the edges in this graph.
|
Long |
getEndNode(Long aEdge)
Returns the end node of the given edge in this graph.
|
Enumeration<Long> |
getNodes()
Returns an Enumeration containing all nodes in this graph.
|
Long |
getOppositeNode(Long aEdge,
Long aNode)
If
aNode is one of the two nodes connected by the given edge in this graph, returns the other node,
otherwise throws IllegalArgumentException . |
ILcdShortestRouteDistanceTableProvider<Long,Long> |
getShortestRouteDistanceTableProvider()
Returns the distance table provider containing distance tables for each of the partitions in this
graph.
|
Long |
getStartNode(Long aEdge)
Returns the start node of the given edge in this graph.
|
boolean |
isConnected(Long aEdge,
Long aNode)
Returns true if
aNode is one the nodes to which this edge is connected. |
void |
removeGraphListener(ILcdGraphListener<Long,Long> aGraphListener)
Unregisters the given
ILcdGraphListener from this graph. |
String |
toString() |
void |
updateEdgeValue(Long aEdge,
double aForwardValue,
double aBackwardValue)
Updates the forward and backward edge value for the specified edge.
|
public ILcdEdgeValueFunction<Long,Long> getEdgeValueFunction()
null
if this graph has no associated edge weights.public ILcdShortestRouteDistanceTableProvider<Long,Long> getShortestRouteDistanceTableProvider()
null
if this graph has no associated weight.public Long createAndAddNode(int aFireEventMode)
aFireEventMode
- the mode for sending out the TLcdGraphChangedEvent. This
can be one of ILcdFireEventMode.FIRE_NOW,
ILcdFireEventMode.FIRE_LATER or ILcdFireEventMode.NO_EVENT
.IllegalStateException
- if the partition to which the new edge should be added already
contains its maximum number of edges.public Long createAndAddEdge(Long aStartNode, Long aEndNode, int aFireEventMode)
Double.POSITIVE_INFINITY
, and can be adjusted afterwards via the updateEdgeValue()
method.aStartNode
- the numerical id of the start node connected to the new edge.aEndNode
- the numerical id of the end node connected to the new edge.aFireEventMode
- the mode for sending out the TLcdGraphChangedEvent. This
can be one of ILcdFireEventMode.FIRE_NOW,
ILcdFireEventMode.FIRE_LATER or ILcdFireEventMode.NO_EVENT
.
containsNode(aStartNode) && containsNode(aEndNode)
IllegalStateException
- if the partition to which the new edge should be added already
contains its maximum number of edges.updateEdgeValue(Long, double, double)
public void updateEdgeValue(Long aEdge, double aForwardValue, double aBackwardValue)
aEdge
- the numerical id of the edge to be updated.aForwardValue
- the new forward edge value.aBackwardValue
- the new backward edge value.public void fireCollectedGraphChanges()
fireCollectedGraphChanges()
.
Note that a fireCollectedGraphChanges()
call is made whenever
a graph event is generated in the ILcdFireEventMode.FIRE_NOW
,
to guarantee the correct order of the events.public boolean containsEdge(Long aEdge)
ILcdGraph
aEdge
is contained in this graph, false otherwise.containsEdge
in interface ILcdGraph<Long,Long>
aEdge
- the edge to be checkedtrue
if aEdge
is part of the graph, false
otherwise.public boolean containsNode(Long aNode)
ILcdGraph
aNode
is part of this graph, false otherwise.containsNode
in interface ILcdGraph<Long,Long>
aNode
- the node to be checked.true
if aNode
is part of the graph, false
otherwise.public Enumeration<Long> getEdges()
ILcdGraph
public Enumeration<Long> getEdges(Long aNode)
ILcdGraph
public Long getEndNode(Long aEdge)
ILcdGraph
getEndNode
in interface ILcdGraph<Long,Long>
aEdge
- the edge whose end node should be returned.public Enumeration<Long> getNodes()
ILcdGraph
public Long getOppositeNode(Long aEdge, Long aNode)
ILcdGraph
aNode
is one of the two nodes connected by the given edge in this graph, returns the other node,
otherwise throws IllegalArgumentException
.getOppositeNode
in interface ILcdGraph<Long,Long>
aEdge
- the edge whose opposite node should be returned.aNode
- one of the two Object
's connected by the given edge.aNode
is one of the two nodes connected by this edge, returns the other
node connected by this edge.public Long getStartNode(Long aEdge)
ILcdGraph
getStartNode
in interface ILcdGraph<Long,Long>
aEdge
- the edge whose start node should be returned.public boolean isConnected(Long aEdge, Long aNode)
ILcdGraph
aNode
is one the nodes to which this edge is connected.isConnected
in interface ILcdGraph<Long,Long>
aEdge
- the edge whose connectivity should be checked.aNode
- the node whose connectivity should be checked.aNode
is one the nodes to which this edge is connected.public void addGraphListener(ILcdGraphListener<Long,Long> aGraphListener)
ILcdGraph
ILcdGraphListener
with this graph. All events
generated by this graph afterwards will be sent to the given listener, until
it is removed from this graph.addGraphListener
in interface ILcdGraph<Long,Long>
aGraphListener
- the graph listener to be registered with this graph.public void removeGraphListener(ILcdGraphListener<Long,Long> aGraphListener)
ILcdGraph
ILcdGraphListener
from this graph. After it
has been unregistered, no events generated by this graph will be sent to the
given listener anymore.removeGraphListener
in interface ILcdGraph<Long,Long>
aGraphListener
- the graph listener to be unregistered from this graph.