Package org.opentrafficsim.core.network
Interface Network
-
- All Superinterfaces:
Definitions,EventProducerInterface,Identifiable
- All Known Implementing Classes:
ExpansionNetwork,OTSNetwork
public interface Network extends Definitions, EventProducerInterface, Identifiable
Interface that defines what information a network should be able to provide about Nodes, Links and Routes.Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
$LastChangedDate: 2020-08-11 11:54:51 +0200 (Tue, 11 Aug 2020) $, @version $Revision: 6530 $, by $Author: averbraeck $, initial version Jul 22, 2015
BSD-style license. See OpenTrafficSim License.- Author:
- Alexander Verbraeck, Peter Knoppers, Guus Tamminga
-
-
Field Summary
Fields Modifier and Type Field Description static TimedEventTypeANIMATION_GENERATOR_ADD_EVENTThe timed event type for pub/sub indicating the addition of an GTUGenerator implementing object.static TimedEventTypeANIMATION_GENERATOR_REMOVE_EVENTThe timed event type for pub/sub indicating the removal of an GTUGenerator implementing object.static TimedEventTypeANIMATION_GTU_ADD_EVENTThe timed event type for pub/sub indicating the addition of a GTU to the network.static TimedEventTypeANIMATION_GTU_REMOVE_EVENTThe timed event type for pub/sub indicating the removal of a GTU from the network.static TimedEventTypeANIMATION_INVISIBLE_OBJECT_ADD_EVENTThe timed event type for pub/sub indicating the addition of an InvisibleObjectInterface implementing object.static TimedEventTypeANIMATION_INVISIBLE_OBJECT_REMOVE_EVENTThe timed event type for pub/sub indicating the removal of an InvisibleObjectInterface implementing object.static TimedEventTypeANIMATION_LINK_ADD_EVENTThe timed event type for pub/sub indicating the addition of a Link.static TimedEventTypeANIMATION_LINK_REMOVE_EVENTThe timed event type for pub/sub indicating the removal of a Link.static TimedEventTypeANIMATION_NODE_ADD_EVENTThe timed event type for pub/sub indicating the addition of a Node.static TimedEventTypeANIMATION_NODE_REMOVE_EVENTThe timed event type for pub/sub indicating the removal of a Node.static TimedEventTypeANIMATION_OBJECT_ADD_EVENTThe timed event type for pub/sub indicating the addition of an ObjectInterface implementing object.static TimedEventTypeANIMATION_OBJECT_REMOVE_EVENTThe timed event type for pub/sub indicating the removal of an ObjectInterface implementing object.static TimedEventTypeANIMATION_ROUTE_ADD_EVENTThe timed event type for pub/sub indicating the addition of a Route for a gtuType.static TimedEventTypeANIMATION_ROUTE_REMOVE_EVENTThe timed event type for pub/sub indicating the removal of a Route for a gtuType.static TimedEventTypeGENERATOR_ADD_EVENTThe timed event type for pub/sub indicating the addition of a GTUGenerator to the network.static TimedEventTypeGENERATOR_REMOVE_EVENTThe timed event type for pub/sub indicating the removal of a GTUGenerator from the network.static TimedEventTypeGTU_ADD_EVENTThe timed event type for pub/sub indicating the addition of a GTU to the network.static TimedEventTypeGTU_REMOVE_EVENTThe timed event type for pub/sub indicating the removal of a GTU from the network.static TimedEventTypeINVISIBLE_OBJECT_ADD_EVENTThe timed event type for pub/sub indicating the addition of an InvisibleObjectInterface implementing object.static TimedEventTypeINVISIBLE_OBJECT_REMOVE_EVENTThe timed event type for pub/sub indicating the removal of an InvisibleObjectInterface implementing object.static TimedEventTypeLINK_ADD_EVENTThe timed event type for pub/sub indicating the addition of a Link.static TimedEventTypeLINK_REMOVE_EVENTThe timed event type for pub/sub indicating the removal of a Link.static TimedEventTypeNODE_ADD_EVENTThe timed event type for pub/sub indicating the addition of a Node.static TimedEventTypeNODE_REMOVE_EVENTThe timed event type for pub/sub indicating the removal of a Node.static TimedEventTypeOBJECT_ADD_EVENTThe timed event type for pub/sub indicating the addition of an ObjectInterface implementing object.static TimedEventTypeOBJECT_REMOVE_EVENTThe timed event type for pub/sub indicating the removal of an ObjectInterface implementing object.static TimedEventTypeROUTE_ADD_EVENTThe timed event type for pub/sub indicating the addition of a Route for a gtuType.static TimedEventTypeROUTE_REMOVE_EVENTThe timed event type for pub/sub indicating the removal of a Route for a gtuType.-
Fields inherited from interface org.djutils.event.EventProducerInterface
FIRST_POSITION, LAST_POSITION
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidaddInvisibleObject(InvisibleObjectInterface object)Add an ObjectInterface implementing object to the Network.voidaddLink(Link link)Register a link in the network.voidaddNode(Node node)Register a node in the network.voidaddObject(ObjectInterface object)Add an ObjectInterface implementing object to the Network.voidaddRoute(GTUType gtuType, Route route)Add a route to the network.voidbuildGraph(GTUType gtuType)(Re)build the underlying graph for the given GTUType.booleancontainsInvisibleObject(String objectId)Test whether an invisible object with the given id is present in the Network.booleancontainsInvisibleObject(InvisibleObjectInterface object)Test whether the invisible object is present in the Network.booleancontainsLink(String link)Test whether a link with a given id is present in the network.booleancontainsLink(Link link)Test whether a link is present in the network.booleancontainsNode(String nodeId)Test whether a node with a given id is present in the network.booleancontainsNode(Node node)Test whether a node is present in the network.booleancontainsObject(String objectId)Test whether an object with the given id is present in the Network.booleancontainsObject(ObjectInterface object)Test whether the object is present in the Network.booleancontainsRoute(GTUType gtuType, String routeId)Determine whether a route with the given id exists in the network for the given GTUType.booleancontainsRoute(GTUType gtuType, Route route)Determine whether the provided route exists in the network for the given GTUType.ImmutableMap<String,Route>getDefinedRouteMap(GTUType gtuType)Return an immutable map of routes that exist in the network for the GTUType.StringgetId()ImmutableMap<String,InvisibleObjectInterface>getInvisibleObjectMap()Return an immutable map of all InvisibleObject implementing objects in the Network.ImmutableMap<String,InvisibleObjectInterface>getInvisibleObjectMap(Class<InvisibleObjectInterface> objectType)Return an immutable map of all InvisibleObject implementing objects in the network that are of type objectType, or any sub type thereof.LinkgetLink(String linkId)Retrieve a node with a given id from the network, or null if the id cannot be found.LinkgetLink(String nodeId1, String nodeId2)Find a link between node1 and node2 and return it if it exists in the network.LinkgetLink(Node node1, Node node2)Find a link between node1 and node2 and return it if it exists in the network.ImmutableMap<String,Link>getLinkMap()Provide an immutable map of link ids to links in the network.NodegetNode(String nodeId)Retrieve a node with a given id from the network, or null if the id cannot be found.ImmutableMap<String,Node>getNodeMap()Provide an immutable map of node ids to nodes in the network.<T extends ObjectInterface>
TgetObject(Class<T> objectType, String objectId)Return object of given type with given id.ImmutableMap<String,ObjectInterface>getObjectMap()Return an immutable map of all ObjectInterface implementing objects in the Network.<T extends ObjectInterface>
ImmutableMap<String,T>getObjectMap(Class<T> objectType)Return an immutable map of all ObjectInterface implementing objects in the network that are of type objectType, or any sub type thereof.RoutegetRoute(GTUType gtuType, String routeId)Return the route with the given id in the network for the given GTUType, or null if it the route with the id does not exist.Set<Route>getRoutesBetween(GTUType gtuType, Node nodeFrom, Node nodeTo)Return the the shortest route between two nodes in the network, via a list of intermediate nodes.default CompleteRoutegetShortestRouteBetween(GTUType gtuType, Node nodeFrom, Node nodeTo)Calculate the shortest route between two nodes in the network.default CompleteRoutegetShortestRouteBetween(GTUType gtuType, Node nodeFrom, Node nodeTo, List<Node> nodesVia)Calculate the shortest route between two nodes in the network, via a list of intermediate nodes.CompleteRoutegetShortestRouteBetween(GTUType gtuType, Node nodeFrom, Node nodeTo, List<Node> nodesVia, LinkWeight linkWeight)Calculate the shortest route between two nodes in the network, via a list of intermediate nodes.CompleteRoutegetShortestRouteBetween(GTUType gtuType, Node nodeFrom, Node nodeTo, LinkWeight linkWeight)Calculate the shortest route between two nodes in the network.OTSSimulatorInterfacegetSimulator()Return the simulator.voidremoveInvisibleObject(InvisibleObjectInterface object)Remove an ObjectInterface implementing object form the Network.voidremoveLink(Link link)Unregister a link from the network.voidremoveNode(Node node)Unregister a node from the network.voidremoveObject(ObjectInterface object)Remove an ObjectInterface implementing object form the Network.voidremoveRoute(GTUType gtuType, Route route)Remove the route from the network, e.g.-
Methods inherited from interface org.opentrafficsim.core.definitions.Definitions
addDefaultGtuTypes, addDefaultLinkTypes, addGtuType, addLinkType, getGtuType, getGtuType, getGtuTypes, getLinkType, getLinkType, getLinkTypes
-
Methods inherited from interface org.djutils.event.EventProducerInterface
addListener, addListener, addListener, addListener, getEventTypesWithListeners, getSourceId, hasListeners, numberOfListeners, removeListener
-
-
-
-
Field Detail
-
ANIMATION_NODE_ADD_EVENT
static final TimedEventType ANIMATION_NODE_ADD_EVENT
The timed event type for pub/sub indicating the addition of a Node.
Payload: Node node (not an array, just an Object)
-
ANIMATION_NODE_REMOVE_EVENT
static final TimedEventType ANIMATION_NODE_REMOVE_EVENT
The timed event type for pub/sub indicating the removal of a Node.
Payload: Node node (not an array, just an Object)
-
ANIMATION_LINK_ADD_EVENT
static final TimedEventType ANIMATION_LINK_ADD_EVENT
The timed event type for pub/sub indicating the addition of a Link.
Payload: Link link (not an array, just an Object)
-
ANIMATION_LINK_REMOVE_EVENT
static final TimedEventType ANIMATION_LINK_REMOVE_EVENT
The timed event type for pub/sub indicating the removal of a Link.
Payload: Link link (not an array, just an Object)
-
ANIMATION_OBJECT_ADD_EVENT
static final TimedEventType ANIMATION_OBJECT_ADD_EVENT
The timed event type for pub/sub indicating the addition of an ObjectInterface implementing object.
Payload: StaticObject object (not an array, just an Object)
-
ANIMATION_OBJECT_REMOVE_EVENT
static final TimedEventType ANIMATION_OBJECT_REMOVE_EVENT
The timed event type for pub/sub indicating the removal of an ObjectInterface implementing object.
Payload: StaticObject object (not an array, just an Object)
-
ANIMATION_INVISIBLE_OBJECT_ADD_EVENT
static final TimedEventType ANIMATION_INVISIBLE_OBJECT_ADD_EVENT
The timed event type for pub/sub indicating the addition of an InvisibleObjectInterface implementing object.
TODO: explain why invisible objects have associated animation events (or remove them from the Network interface)
Payload: InvisibleObject object (not an array, just an Object)
-
ANIMATION_INVISIBLE_OBJECT_REMOVE_EVENT
static final TimedEventType ANIMATION_INVISIBLE_OBJECT_REMOVE_EVENT
The timed event type for pub/sub indicating the removal of an InvisibleObjectInterface implementing object.
Payload: InvisibleObject object (not an array, just an Object)
-
ANIMATION_ROUTE_ADD_EVENT
static final TimedEventType ANIMATION_ROUTE_ADD_EVENT
The timed event type for pub/sub indicating the addition of a Route for a gtuType.
Payload: [GTUType gtuType, Route route]
-
ANIMATION_ROUTE_REMOVE_EVENT
static final TimedEventType ANIMATION_ROUTE_REMOVE_EVENT
The timed event type for pub/sub indicating the removal of a Route for a gtuType.
Payload: [GTUType gtuType, Route route]
-
ANIMATION_GTU_ADD_EVENT
static final TimedEventType ANIMATION_GTU_ADD_EVENT
The timed event type for pub/sub indicating the addition of a GTU to the network.
Payload: GTU gtu (not an array, just an Object)
-
ANIMATION_GTU_REMOVE_EVENT
static final TimedEventType ANIMATION_GTU_REMOVE_EVENT
The timed event type for pub/sub indicating the removal of a GTU from the network.
Payload: GTU gtu (not an array, just an Object)
-
ANIMATION_GENERATOR_ADD_EVENT
static final TimedEventType ANIMATION_GENERATOR_ADD_EVENT
The timed event type for pub/sub indicating the addition of an GTUGenerator implementing object.
Payload: AbstractGTUGenerator object (not an array, just an Object)
TODO: there seems to be no specific class or interface for these that can be specified in the ObjectDescriptor
-
ANIMATION_GENERATOR_REMOVE_EVENT
static final TimedEventType ANIMATION_GENERATOR_REMOVE_EVENT
The timed event type for pub/sub indicating the removal of an GTUGenerator implementing object.
Payload: AbstractGTUGenerator object (not an array, just an Object)
TODO: there seems to be no specific class or interface for these that can be specified in the ObjectDescriptor
-
NODE_ADD_EVENT
static final TimedEventType NODE_ADD_EVENT
The timed event type for pub/sub indicating the addition of a Node.
Payload: String nodeId (not an array, just a String)
-
NODE_REMOVE_EVENT
static final TimedEventType NODE_REMOVE_EVENT
The timed event type for pub/sub indicating the removal of a Node.
Payload: String nodeId (not an array, just a String)
-
LINK_ADD_EVENT
static final TimedEventType LINK_ADD_EVENT
The timed event type for pub/sub indicating the addition of a Link.
Payload: String linkId (not an array, just a String)
-
LINK_REMOVE_EVENT
static final TimedEventType LINK_REMOVE_EVENT
The timed event type for pub/sub indicating the removal of a Link.
Payload: String linkId (not an array, just a String)
-
OBJECT_ADD_EVENT
static final TimedEventType OBJECT_ADD_EVENT
The timed event type for pub/sub indicating the addition of an ObjectInterface implementing object.
Payload: String ObjectId (not an array, just a String)
-
OBJECT_REMOVE_EVENT
static final TimedEventType OBJECT_REMOVE_EVENT
The timed event type for pub/sub indicating the removal of an ObjectInterface implementing object.
Payload: String objectId (not an array, just a String)
-
INVISIBLE_OBJECT_ADD_EVENT
static final TimedEventType INVISIBLE_OBJECT_ADD_EVENT
The timed event type for pub/sub indicating the addition of an InvisibleObjectInterface implementing object.
Payload: String ObjectId (not an array, just a String)
-
INVISIBLE_OBJECT_REMOVE_EVENT
static final TimedEventType INVISIBLE_OBJECT_REMOVE_EVENT
The timed event type for pub/sub indicating the removal of an InvisibleObjectInterface implementing object.
Payload: String objectId (not an array, just a String)
-
ROUTE_ADD_EVENT
static final TimedEventType ROUTE_ADD_EVENT
The timed event type for pub/sub indicating the addition of a Route for a gtuType.
Payload: [String gtuTypeId, String routeId]
-
ROUTE_REMOVE_EVENT
static final TimedEventType ROUTE_REMOVE_EVENT
The timed event type for pub/sub indicating the removal of a Route for a gtuType.
Payload: [String gtuTypeId, String routeId]
-
GTU_ADD_EVENT
static final TimedEventType GTU_ADD_EVENT
The timed event type for pub/sub indicating the addition of a GTU to the network.
Payload: String gtuId (not an array, just a String)
-
GTU_REMOVE_EVENT
static final TimedEventType GTU_REMOVE_EVENT
The timed event type for pub/sub indicating the removal of a GTU from the network.
Payload: String gtuId (not an array, just a String)
-
GENERATOR_ADD_EVENT
static final TimedEventType GENERATOR_ADD_EVENT
The timed event type for pub/sub indicating the addition of a GTUGenerator to the network.
Payload: String generatorName (not an array, just a String)
-
GENERATOR_REMOVE_EVENT
static final TimedEventType GENERATOR_REMOVE_EVENT
The timed event type for pub/sub indicating the removal of a GTUGenerator from the network.
Payload: String generatorName (not an array, just a String)
-
-
Method Detail
-
getId
String getId()
- Specified by:
getIdin interfaceIdentifiable- Returns:
- String; the id
-
getSimulator
OTSSimulatorInterface getSimulator()
Return the simulator.- Returns:
- OTSSimulatorInterface; the simulator
-
getNodeMap
ImmutableMap<String,Node> getNodeMap()
Provide an immutable map of node ids to nodes in the network.- Returns:
- an immutable map of nodes.
-
addNode
void addNode(Node node) throws NetworkException
Register a node in the network.- Parameters:
node- Node; the node to add to the network.- Throws:
NetworkException- if node already exists in the network, or if name of the node is not unique.
-
removeNode
void removeNode(Node node) throws NetworkException
Unregister a node from the network.- Parameters:
node- Node; the node to remove from the network.- Throws:
NetworkException- if node does not exist in the network.
-
containsNode
boolean containsNode(Node node)
Test whether a node is present in the network.- Parameters:
node- Node; the node to search for in the network.- Returns:
- whether the node is in this network
-
containsNode
boolean containsNode(String nodeId)
Test whether a node with a given id is present in the network.- Parameters:
nodeId- String; the id of the node to search for in the network.- Returns:
- whether the node is in this network
-
getNode
Node getNode(String nodeId)
Retrieve a node with a given id from the network, or null if the id cannot be found.- Parameters:
nodeId- String; the id of the node to search for in the network.- Returns:
- the node or null if not present
-
getLinkMap
ImmutableMap<String,Link> getLinkMap()
Provide an immutable map of link ids to links in the network.- Returns:
- the an immutable map of links.
-
addLink
void addLink(Link link) throws NetworkException
Register a link in the network.- Parameters:
link- Link; the link to add to the network.- Throws:
NetworkException- if link already exists in the network, if name of the link is not unique, or if the start node or the end node of the link are not registered in the network.
-
removeLink
void removeLink(Link link) throws NetworkException
Unregister a link from the network.- Parameters:
link- Link; the link to remove from the network.- Throws:
NetworkException- if link does not exist in the network.
-
containsLink
boolean containsLink(Link link)
Test whether a link is present in the network.- Parameters:
link- Link; the link to search for in the network.- Returns:
- whether the link is in this network
-
containsLink
boolean containsLink(String link)
Test whether a link with a given id is present in the network.- Parameters:
link- String; the id of the link to search for in the network.- Returns:
- whether the link is in this network
-
getLink
Link getLink(String linkId)
Retrieve a node with a given id from the network, or null if the id cannot be found.- Parameters:
linkId- String; the id of the link to search for in the network.- Returns:
- the link or null if not present
-
getLink
Link getLink(Node node1, Node node2)
Find a link between node1 and node2 and return it if it exists in the network. If not, return null.- Parameters:
node1- Node; first nodenode2- Node; second node- Returns:
- the link between node1 and node2 in the network or null if it does not exist.
-
getLink
Link getLink(String nodeId1, String nodeId2) throws NetworkException
Find a link between node1 and node2 and return it if it exists in the network. If not, return null.- Parameters:
nodeId1- String; id of the first nodenodeId2- String; id of the second node- Returns:
- the link between node1 and node2 in the network or null if it does not exist.
- Throws:
NetworkException- if the node(s) cannot be found by their id
-
getObjectMap
ImmutableMap<String,ObjectInterface> getObjectMap()
Return an immutable map of all ObjectInterface implementing objects in the Network.- Returns:
- ImmutableMap<String, ObjectInterface>; the immutable map of all ObjectInterface implementing objects in the Network
-
getObjectMap
<T extends ObjectInterface> ImmutableMap<String,T> getObjectMap(Class<T> objectType)
Return an immutable map of all ObjectInterface implementing objects in the network that are of type objectType, or any sub type thereof.- Type Parameters:
T- type of object- Parameters:
objectType- Class<T>; the (sub-)type of ObjectInterface that the returned map is reduced to- Returns:
- ImmutableMap<String, ObjectInterface>; the immutable map of all ObjectInterface implementing objects in the Network that are of the type objectType, or any sub type thereof
-
getObject
<T extends ObjectInterface> T getObject(Class<T> objectType, String objectId)
Return object of given type with given id.- Type Parameters:
T- object type- Parameters:
objectType- T; object type classobjectId- String; id of object- Returns:
- T; object of given type with given id,
nullif no such object
-
addObject
void addObject(ObjectInterface object) throws NetworkException
Add an ObjectInterface implementing object to the Network.- Parameters:
object- ObjectInterface; the object that implements ObjectInterface- Throws:
NetworkException- if link already exists in the network, if name of the object is not unique.
-
removeObject
void removeObject(ObjectInterface object) throws NetworkException
Remove an ObjectInterface implementing object form the Network.- Parameters:
object- ObjectInterface; the object that implements ObjectInterface- Throws:
NetworkException- if the object does not exist in the network.
-
containsObject
boolean containsObject(ObjectInterface object)
Test whether the object is present in the Network.- Parameters:
object- ObjectInterface; the object that is tested for presence- Returns:
- boolean; whether the object is present in the Network
-
containsObject
boolean containsObject(String objectId)
Test whether an object with the given id is present in the Network.- Parameters:
objectId- String; the id that is tested for presence- Returns:
- boolean; whether an object with the given id is present in the Network
-
getInvisibleObjectMap
ImmutableMap<String,InvisibleObjectInterface> getInvisibleObjectMap()
Return an immutable map of all InvisibleObject implementing objects in the Network.- Returns:
- ImmutableMap<String, ObjectInterface>; the immutable map of all ObjectInterface implementing objects in the Network
-
getInvisibleObjectMap
ImmutableMap<String,InvisibleObjectInterface> getInvisibleObjectMap(Class<InvisibleObjectInterface> objectType)
Return an immutable map of all InvisibleObject implementing objects in the network that are of type objectType, or any sub type thereof.- Parameters:
objectType- Class<InvisibleObjectInterface>; the (sub-)type of InvisibleObject that the returned map is reduced to- Returns:
- ImmutableMap<String, InvisibleObject>; the immutable map of all InvisibleObject implementing objects in the Network that are of the type objectType, or any sub type thereof
-
addInvisibleObject
void addInvisibleObject(InvisibleObjectInterface object) throws NetworkException
Add an ObjectInterface implementing object to the Network.- Parameters:
object- InvisibleObjectInterface; the object that implements ObjectInterface- Throws:
NetworkException- if link already exists in the network, if name of the object is not unique.
-
removeInvisibleObject
void removeInvisibleObject(InvisibleObjectInterface object) throws NetworkException
Remove an ObjectInterface implementing object form the Network.- Parameters:
object- InvisibleObjectInterface; the object that implements ObjectInterface- Throws:
NetworkException- if the object does not exist in the network.
-
containsInvisibleObject
boolean containsInvisibleObject(InvisibleObjectInterface object)
Test whether the invisible object is present in the Network.- Parameters:
object- InvisibleObjectInterface; the object that is tested for presence- Returns:
- boolean; whether the invisible object is present in the Network
-
containsInvisibleObject
boolean containsInvisibleObject(String objectId)
Test whether an invisible object with the given id is present in the Network.- Parameters:
objectId- String; the id that is tested for presence- Returns:
- boolean; whether an invisible object with the given id is present in the Network
-
getDefinedRouteMap
ImmutableMap<String,Route> getDefinedRouteMap(GTUType gtuType)
Return an immutable map of routes that exist in the network for the GTUType.- Parameters:
gtuType- GTUType; the GTUType for which to retrieve the defined routes- Returns:
- an immutable map of routes in the network for the given GTUType, or an empty Map if no routes are defined for the given GTUType.
-
addRoute
void addRoute(GTUType gtuType, Route route) throws NetworkException
Add a route to the network.- Parameters:
gtuType- GTUType; the GTUType for which to add a routeroute- Route; the route to add to the network.- Throws:
NetworkException- if route already exists in the network, if name of the route is not unique, if one of the nodes of the route are not registered in the network.
-
removeRoute
void removeRoute(GTUType gtuType, Route route) throws NetworkException
Remove the route from the network, e.g. because of road maintenance.- Parameters:
gtuType- GTUType; the GTUType for which to remove a routeroute- Route; the route to remove from the network.- Throws:
NetworkException- if route does not exist in the network.
-
getRoute
Route getRoute(GTUType gtuType, String routeId)
Return the route with the given id in the network for the given GTUType, or null if it the route with the id does not exist.- Parameters:
gtuType- GTUType; the GTUType for which to retrieve a route based on its id.routeId- String; the route to search for in the network.- Returns:
- the route or null if not present
-
containsRoute
boolean containsRoute(GTUType gtuType, Route route)
Determine whether the provided route exists in the network for the given GTUType.- Parameters:
gtuType- GTUType; the GTUType for which to check whether the route existsroute- Route; the route to check for- Returns:
- whether the route exists in the network for the given GTUType
-
containsRoute
boolean containsRoute(GTUType gtuType, String routeId)
Determine whether a route with the given id exists in the network for the given GTUType.- Parameters:
gtuType- GTUType; the GTUType for which to check whether the route existsrouteId- String; the id of the route to check for- Returns:
- whether a route with the given id exists in the network for the given GTUType
-
getRoutesBetween
Set<Route> getRoutesBetween(GTUType gtuType, Node nodeFrom, Node nodeTo)
Return the the shortest route between two nodes in the network, via a list of intermediate nodes. If no path exists from the start node to the end node via the intermediate nodes in the network, null is returned.- Parameters:
gtuType- GTUType; the GTUType for which to retrieve the defined routesnodeFrom- Node; the start node.nodeTo- Node; the end node.- Returns:
- a set with routes from the start Node to the end Node in the network; if no route can be found, an empty set is returned.
-
buildGraph
void buildGraph(GTUType gtuType)
(Re)build the underlying graph for the given GTUType.- Parameters:
gtuType- GTUType; the GTUType for which to (re)build the graph
-
getShortestRouteBetween
default CompleteRoute getShortestRouteBetween(GTUType gtuType, Node nodeFrom, Node nodeTo) throws NetworkException
Calculate the shortest route between two nodes in the network. If no path exists from the start node to the end node in the network, null is returned. This method returns a CompleteRoute, which includes all nodes to get from start to end. In case the graph for the GTUType has not yet been built, this method will call the buildGraph method.- Parameters:
gtuType- GTUType; the GTUType for which to calculate the shortest routenodeFrom- Node; the start node.nodeTo- Node; the end node.- Returns:
- the shortest route from the start Node to the end Node in the network. If no path exists from the start node to the end node in the network, null is returned.
- Throws:
NetworkException- in case nodes cannot be added to the route, e.g. because they are not directly connected. This can be the case when the links in the network have changed, but the graph has not been rebuilt.
-
getShortestRouteBetween
CompleteRoute getShortestRouteBetween(GTUType gtuType, Node nodeFrom, Node nodeTo, LinkWeight linkWeight) throws NetworkException
Calculate the shortest route between two nodes in the network. If no path exists from the start node to the end node in the network, null is returned. This method returns a CompleteRoute, which includes all nodes to get from start to end. This method recalculates the graph.- Parameters:
gtuType- GTUType; the GTUType for which to calculate the shortest routenodeFrom- Node; the start node.nodeTo- Node; the end node.linkWeight- LinkWeight; link weight.- Returns:
- the shortest route from the start Node to the end Node in the network. If no path exists from the start node to the end node in the network, null is returned.
- Throws:
NetworkException- in case nodes cannot be added to the route, e.g. because they are not directly connected. This can be the case when the links in the network have changed, but the graph has not been rebuilt.
-
getShortestRouteBetween
default CompleteRoute getShortestRouteBetween(GTUType gtuType, Node nodeFrom, Node nodeTo, List<Node> nodesVia) throws NetworkException
Calculate the shortest route between two nodes in the network, via a list of intermediate nodes. If no path exists from the start node to the end node via the intermediate nodes in the network, null is returned. This method returns a CompleteRoute, which includes all nodes to get from start to end. In case the graph for the GTUType has not yet been built, this method will call the buildGraph method.- Parameters:
gtuType- GTUType; the GTUType for which to calculate the shortest routenodeFrom- Node; the start node.nodeTo- Node; the end node.nodesVia- List<Node>; a number of nodes that the GTU has to pass between nodeFrom and nodeTo in the given order.- Returns:
- the shortest route between two nodes in the network, via the intermediate nodes. If no path exists from the start node to the end node via the intermediate nodes in the network, null is returned.
- Throws:
NetworkException- in case nodes cannot be added to the route, e.g. because they are not directly connected. This can be the case when the links in the network have changed, but the graph has not been rebuilt.
-
getShortestRouteBetween
CompleteRoute getShortestRouteBetween(GTUType gtuType, Node nodeFrom, Node nodeTo, List<Node> nodesVia, LinkWeight linkWeight) throws NetworkException
Calculate the shortest route between two nodes in the network, via a list of intermediate nodes. If no path exists from the start node to the end node via the intermediate nodes in the network, null is returned. This method returns a CompleteRoute, which includes all nodes to get from start to end. This method recalculates the graph.- Parameters:
gtuType- GTUType; the GTUType for which to calculate the shortest routenodeFrom- Node; the start node.nodeTo- Node; the end node.nodesVia- List<Node>; a number of nodes that the GTU has to pass between nodeFrom and nodeTo in the given order.linkWeight- LinkWeight; link weight.- Returns:
- the shortest route between two nodes in the network, via the intermediate nodes. If no path exists from the start node to the end node via the intermediate nodes in the network, null is returned.
- Throws:
NetworkException- in case nodes cannot be added to the route, e.g. because they are not directly connected. This can be the case when the links in the network have changed, but the graph has not been rebuilt.
-
-