Package com.graphhopper.storage
Interface Graph
- All Known Implementing Classes:
BaseGraph
,QueryGraph
public interface Graph
An interface to represent a (geo) graph - suited for efficient storage as it can be requested via
indices called node IDs. To get the lat,lon point you need to set up a LocationIndex instance.
- Author:
- Peter Karich
-
Method Summary
Modifier and TypeMethodDescriptiondefault EdgeExplorer
Creates an EdgeExplorer that accepts all edgescreateEdgeExplorer
(EdgeFilter filter) Returns an EdgeExplorer which makes it possible to traverse all filtered edges of a specific node.edge
(int a, int b) Creates an edge between the nodes a and b.Returns the implicit bounds of this graph calculated from the lat,lon input of setNodegetEdgeIteratorState
(int edgeId, int adjNode) Returns a wrapper over the specified edgeId.getEdgeIteratorStateForKey
(int edgeKey) Returns the edge state for the given edge keyint
getEdges()
Creates an object to access node properties.int
getNodes()
int
getOtherNode
(int edge, int node) boolean
isAdjacentToNode
(int edge, int node) wrapWeighting
(Weighting weighting) Wraps the given weighting into a weighting that can be used by this graph
-
Method Details
-
getBaseGraph
BaseGraph getBaseGraph()- Returns:
- a graph which behaves like an unprepared graph and e.g. the normal unidirectional Dijkstra or any graph traversal algorithm can be executed.
-
getNodes
int getNodes()- Returns:
- the number of created locations - via setNode() or edge()
-
getEdges
int getEdges()- Returns:
- the number of edges in this graph. Equivalent to getAllEdges().length().
-
getNodeAccess
NodeAccess getNodeAccess()Creates an object to access node properties. -
getBounds
BBox getBounds()Returns the implicit bounds of this graph calculated from the lat,lon input of setNode -
edge
Creates an edge between the nodes a and b. To set distance or access use the returned edge and e.g. edgeState.setDistance- Parameters:
a
- the index of the starting (tower) node of the edgeb
- the index of the ending (tower) node of the edge- Returns:
- the newly created edge
-
getEdgeIteratorState
Returns a wrapper over the specified edgeId.- Parameters:
adjNode
- is the node that will be returned via getAdjNode(). If adjNode is Integer.MIN_VALUE then the edge will be returned in the direction of how it is stored- Returns:
- a new EdgeIteratorState object or potentially null if adjNode does not match
- Throws:
IllegalStateException
- if edgeId is not valid
-
getEdgeIteratorStateForKey
Returns the edge state for the given edge key- See Also:
-
getOtherNode
int getOtherNode(int edge, int node) - Returns:
- the 'opposite' node of a given edge, so if there is an edge 3-2 and node =2 this returns 3
-
isAdjacentToNode
boolean isAdjacentToNode(int edge, int node) - Returns:
- true if the edge with id edge is adjacent to node, false otherwise
-
getAllEdges
AllEdgesIterator getAllEdges()- Returns:
- all edges in this graph, where baseNode will be the smaller node.
-
createEdgeExplorer
Returns an EdgeExplorer which makes it possible to traverse all filtered edges of a specific node. Calling this method might be expensive, so e.g. create an explorer before a for loop! -
createEdgeExplorer
Creates an EdgeExplorer that accepts all edges- See Also:
-
getTurnCostStorage
TurnCostStorage getTurnCostStorage()- Returns:
- the
TurnCostStorage
or null if not supported
-
wrapWeighting
Wraps the given weighting into a weighting that can be used by this graph
-