Package com.luciad.network.graph.numeric
Class TLcdNumericGraph
java.lang.Object
com.luciad.network.graph.numeric.TLcdNumericGraph
A graph implementation whose nodes, edges and partitions are all represented by a numerical identifer.
Numerical identifiers
The identifier format
In a numerical graph, the graph itself, its subgraphs (partitioned, simple and boundary graphs), all nodes and edges have an identifier that is unique within the whole graph. This identifier is a 64-bit number and is represented in LuciadLightspeed usinglong
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.
Edge values
Besides topology, a numeric graph also provides direct access to:- the edge value function describing the weights of the edges in the graph.
- the distance table provider containing distance tables for each of the partitions in the graph.
null
.
Updating a numerical graph
A numerical graph can be updated using one of the following methods: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 graph
addEdge
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
.- Since:
- 9.1
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addGraphListener
(ILcdGraphListener<Long, Long> aGraphListener) Registers the givenILcdGraphListener
with this graph.boolean
containsEdge
(Long aEdge) Returns true ifaEdge
is contained in this graph, false otherwise.boolean
containsNode
(Long aNode) Returns true ifaNode
is part of this graph, false otherwise.createAndAddEdge
(Long aStartNode, Long aEndNode, int aFireEventMode) Creates and adds a new edge to this graph.createAndAddNode
(int aFireEventMode) Creates and adds a new node to this graph.void
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 tofireCollectedGraphChanges()
.getEdges()
Returns an Enumeration containing all edges in this graph.Returns an Enumeration containing all edges connected to the given node.Returns the edge value function describing the weights of the edges in this graph.getEndNode
(Long aEdge) Returns the end node of the given edge in this graph.getNodes()
Returns an Enumeration containing all nodes in this graph.getOppositeNode
(Long aEdge, Long aNode) IfaNode
is one of the two nodes connected by the given edge in this graph, returns the other node, otherwise throwsIllegalArgumentException
.Returns the distance table provider containing distance tables for each of the partitions in this graph.getStartNode
(Long aEdge) Returns the start node of the given edge in this graph.boolean
isConnected
(Long aEdge, Long aNode) Returns true ifaNode
is one the nodes to which this edge is connected.void
removeGraphListener
(ILcdGraphListener<Long, Long> aGraphListener) Unregisters the givenILcdGraphListener
from this graph.toString()
void
updateEdgeValue
(Long aEdge, double aForwardValue, double aBackwardValue) Updates the forward and backward edge value for the specified edge.
-
Method Details
-
getEdgeValueFunction
Returns the edge value function describing the weights of the edges in this graph.- Returns:
- the edge value function describing the weights of the edges in this graph or
null
if this graph has no associated edge weights.
-
getShortestRouteDistanceTableProvider
Returns the distance table provider containing distance tables for each of the partitions in this graph.- Returns:
- the distance table provider containing distance tables for each of the partitions in this
graph or
null
if this graph has no associated weight.
-
createAndAddNode
Creates and adds a new node to this graph. The graph will automatically compute an identifier for the new node and return it to the user.- Parameters:
aFireEventMode
- the mode for sending out the TLcdGraphChangedEvent. This can be one ofILcdFireEventMode.FIRE_NOW, ILcdFireEventMode.FIRE_LATER or ILcdFireEventMode.NO_EVENT
.- Returns:
- the numerical id of the new node that was added.
- Throws:
IllegalStateException
- if the partition to which the new edge should be added already contains its maximum number of edges.
-
createAndAddEdge
Creates and adds a new edge to this graph. The graph will automatically compute an identifier for the new edge and return it to the user. The traversal cost of the edge will be initialized toDouble.POSITIVE_INFINITY
, and can be adjusted afterwards via theupdateEdgeValue()
method.- Parameters:
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 ofILcdFireEventMode.FIRE_NOW, ILcdFireEventMode.FIRE_LATER or ILcdFireEventMode.NO_EVENT
.- Preconditions:
containsNode(aStartNode) && containsNode(aEndNode)
- Returns:
- the numerical identifier of the new edge that was added.
- Throws:
IllegalStateException
- if the partition to which the new edge should be added already contains its maximum number of edges.- See Also:
-
updateEdgeValue
Updates the forward and backward edge value for the specified edge.- Parameters:
aEdge
- the numerical id of the edge to be updated.aForwardValue
- the new forward edge value.aBackwardValue
- the new backward edge value.
-
fireCollectedGraphChanges
public 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 tofireCollectedGraphChanges()
. Note that afireCollectedGraphChanges()
call is made whenever a graph event is generated in theILcdFireEventMode.FIRE_NOW
, to guarantee the correct order of the events. -
containsEdge
Description copied from interface:ILcdGraph
Returns true ifaEdge
is contained in this graph, false otherwise.- Specified by:
containsEdge
in interfaceILcdGraph<Long,
Long> - Parameters:
aEdge
- the edge to be checked- Returns:
true
ifaEdge
is part of the graph,false
otherwise.
-
containsNode
Description copied from interface:ILcdGraph
Returns true ifaNode
is part of this graph, false otherwise.- Specified by:
containsNode
in interfaceILcdGraph<Long,
Long> - Parameters:
aNode
- the node to be checked.- Returns:
true
ifaNode
is part of the graph,false
otherwise.
-
getEdges
Description copied from interface:ILcdGraph
Returns an Enumeration containing all edges in this graph. -
getEdges
Description copied from interface:ILcdGraph
Returns an Enumeration containing all edges connected to the given node. -
getEndNode
Description copied from interface:ILcdGraph
Returns the end node of the given edge in this graph.- Specified by:
getEndNode
in interfaceILcdGraph<Long,
Long> - Parameters:
aEdge
- the edge whose end node should be returned.- Returns:
- the end node.
-
getNodes
Description copied from interface:ILcdGraph
Returns an Enumeration containing all nodes in this graph. -
getOppositeNode
Description copied from interface:ILcdGraph
IfaNode
is one of the two nodes connected by the given edge in this graph, returns the other node, otherwise throwsIllegalArgumentException
.- Specified by:
getOppositeNode
in interfaceILcdGraph<Long,
Long> - Parameters:
aEdge
- the edge whose opposite node should be returned.aNode
- one of the twoObject
's connected by the given edge.- Returns:
- if
aNode
is one of the two nodes connected by this edge, returns the other node connected by this edge.
-
getStartNode
Description copied from interface:ILcdGraph
Returns the start node of the given edge in this graph.- Specified by:
getStartNode
in interfaceILcdGraph<Long,
Long> - Parameters:
aEdge
- the edge whose start node should be returned.- Returns:
- the start node.
-
isConnected
Description copied from interface:ILcdGraph
Returns true ifaNode
is one the nodes to which this edge is connected.- Specified by:
isConnected
in interfaceILcdGraph<Long,
Long> - Parameters:
aEdge
- the edge whose connectivity should be checked.aNode
- the node whose connectivity should be checked.- Returns:
- true if
aNode
is one the nodes to which this edge is connected.
-
addGraphListener
Description copied from interface:ILcdGraph
Registers the givenILcdGraphListener
with this graph. All events generated by this graph afterwards will be sent to the given listener, until it is removed from this graph.- Specified by:
addGraphListener
in interfaceILcdGraph<Long,
Long> - Parameters:
aGraphListener
- the graph listener to be registered with this graph.
-
removeGraphListener
Description copied from interface:ILcdGraph
Unregisters the givenILcdGraphListener
from this graph. After it has been unregistered, no events generated by this graph will be sent to the given listener anymore.- Specified by:
removeGraphListener
in interfaceILcdGraph<Long,
Long> - Parameters:
aGraphListener
- the graph listener to be unregistered from this graph.
-
toString
-