Class TLcdNumericGraph

java.lang.Object
com.luciad.network.graph.numeric.TLcdNumericGraph
All Implemented Interfaces:
ILcdGraph<Long,Long>

public class TLcdNumericGraph extends Object implements ILcdGraph<Long,Long>
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 using 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.

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.

If a numerical graph is unweighted, its edge value function and distance table provider will be 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
Whenever the 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 Details

    • getEdgeValueFunction

      public ILcdEdgeValueFunction<Long,Long> 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

      public ILcdShortestRouteDistanceTableProvider<Long,Long> 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

      public Long createAndAddNode(int aFireEventMode)
      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 of ILcdFireEventMode.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

      public Long createAndAddEdge(Long aStartNode, Long aEndNode, int aFireEventMode)
      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 to Double.POSITIVE_INFINITY, and can be adjusted afterwards via the updateEdgeValue() 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 of ILcdFireEventMode.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

      public void updateEdgeValue(Long aEdge, double aForwardValue, double aBackwardValue)
      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 to 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.
    • containsEdge

      public boolean containsEdge(Long aEdge)
      Description copied from interface: ILcdGraph
      Returns true if aEdge is contained in this graph, false otherwise.
      Specified by:
      containsEdge in interface ILcdGraph<Long,Long>
      Parameters:
      aEdge - the edge to be checked
      Returns:
      true if aEdge is part of the graph, false otherwise.
    • containsNode

      public boolean containsNode(Long aNode)
      Description copied from interface: ILcdGraph
      Returns true if aNode is part of this graph, false otherwise.
      Specified by:
      containsNode in interface ILcdGraph<Long,Long>
      Parameters:
      aNode - the node to be checked.
      Returns:
      true if aNode is part of the graph, false otherwise.
    • getEdges

      public Enumeration<Long> getEdges()
      Description copied from interface: ILcdGraph
      Returns an Enumeration containing all edges in this graph.
      Specified by:
      getEdges in interface ILcdGraph<Long,Long>
      Returns:
      an Enumeration containing all edges in this graph.
    • getEdges

      public Enumeration<Long> getEdges(Long aNode)
      Description copied from interface: ILcdGraph
      Returns an Enumeration containing all edges connected to the given node.
      Specified by:
      getEdges in interface ILcdGraph<Long,Long>
      Parameters:
      aNode - the node whose connected edges should be returned.
      Returns:
      an Enumeration containing all edges connected to the given node.
    • getEndNode

      public Long getEndNode(Long aEdge)
      Description copied from interface: ILcdGraph
      Returns the end node of the given edge in this graph.
      Specified by:
      getEndNode in interface ILcdGraph<Long,Long>
      Parameters:
      aEdge - the edge whose end node should be returned.
      Returns:
      the end node.
    • getNodes

      public Enumeration<Long> getNodes()
      Description copied from interface: ILcdGraph
      Returns an Enumeration containing all nodes in this graph.
      Specified by:
      getNodes in interface ILcdGraph<Long,Long>
      Returns:
      an Enumeration containing all nodes in this graph.
    • getOppositeNode

      public Long getOppositeNode(Long aEdge, Long aNode)
      Description copied from interface: ILcdGraph
      If aNode is one of the two nodes connected by the given edge in this graph, returns the other node, otherwise throws IllegalArgumentException.
      Specified by:
      getOppositeNode in interface ILcdGraph<Long,Long>
      Parameters:
      aEdge - the edge whose opposite node should be returned.
      aNode - one of the two Object'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

      public Long getStartNode(Long aEdge)
      Description copied from interface: ILcdGraph
      Returns the start node of the given edge in this graph.
      Specified by:
      getStartNode in interface ILcdGraph<Long,Long>
      Parameters:
      aEdge - the edge whose start node should be returned.
      Returns:
      the start node.
    • isConnected

      public boolean isConnected(Long aEdge, Long aNode)
      Description copied from interface: ILcdGraph
      Returns true if aNode is one the nodes to which this edge is connected.
      Specified by:
      isConnected in interface ILcdGraph<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

      public void addGraphListener(ILcdGraphListener<Long,Long> aGraphListener)
      Description copied from interface: ILcdGraph
      Registers the given 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.
      Specified by:
      addGraphListener in interface ILcdGraph<Long,Long>
      Parameters:
      aGraphListener - the graph listener to be registered with this graph.
    • removeGraphListener

      public void removeGraphListener(ILcdGraphListener<Long,Long> aGraphListener)
      Description copied from interface: ILcdGraph
      Unregisters the given ILcdGraphListener 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 interface ILcdGraph<Long,Long>
      Parameters:
      aGraphListener - the graph listener to be unregistered from this graph.
    • toString

      public String toString()
      Overrides:
      toString in class Object