SparkseePython
6.0.2
|
SinglePairShortestPathDijkstra class. More...
Public Member Functions | |
def | __init__ (self, session, src, dst) |
Creates a new instance. More... | |
def | exclude_nodes (self, nodes) |
Set which nodes can't be used. More... | |
def | get_cost (self) |
Gets the cost of the shortest path. More... | |
def | run (self) |
Executes the algorithm. | |
def | add_all_edge_types (self, dir) |
Allows for traversing all edge types of the graph. More... | |
def | exclude_edges (self, edges) |
Set which edges can't be used. More... | |
def | add_edge_type (self, type, dir) |
Allows for traversing edges of the given type. More... | |
def | set_unweighted_edge_cost (self, weight) |
Sets the weight assigned to the unweighted edges. More... | |
def | get_path_as_nodes (self) |
Gets the shortest path between the source node and the destination node as an ordered set of nodes. More... | |
def | set_dynamic_edge_cost_callback (self, dyn_cost_calculator) |
Set a class callback to dynamically calculate the cost of the edges. More... | |
def | add_node_type (self, type) |
Allows for traversing nodes of the given type. More... | |
def | exists (self) |
Returns TRUE If a path exists or FALSE otherwise. | |
def | get_path_as_edges (self) |
Gets the shortest path between the source node and the destination node as an ordered set of edges. More... | |
def | add_weighted_edge_type (self, type, dir, attr) |
Allows for traversing edges of the given type using the given attribute as the weight. More... | |
def | set_maximum_hops (self, maxhops) |
Sets the maximum hops restriction. More... | |
def | add_all_node_types (self) |
Allows for traversing all node types of the graph. | |
def | close (self) |
Closes the ShortestPath instance. More... | |
def | is_closed (self) |
Gets if ShortestPath has been closed or not. More... | |
SinglePairShortestPathDijkstra class.
It solves the single-pair shortest path problem using a Dijkstra-based implementation.
It is a weighted algorithm, so it takes into account the cost of the edges to compute a minimum-cost shortest path. That is, the user may set for each edge type which attribute should be used to retrieve the cost of the edge. If no attribute is given for an edge type, this will assume the edge has a fixed cost (the default is 1). Only numerical attribute can be set as weight attributes (that is Long, Integer or Double attributes are allowed).
Check out the 'Algorithms' section in the SPARKSEE User Manual for more details on this.
def sparksee.SinglePairShortestPathDijkstra.__init__ | ( | self, | |
session, | |||
src, | |||
dst | |||
) |
Creates a new instance.
session | [in] Session to get the graph from and perform traversal. |
src | [in] Source node. |
dst | [dst] Destination node. |
def sparksee.SinglePairShortestPathDijkstra.add_all_edge_types | ( | self, | |
dir | |||
) |
Allows for traversing all edge types of the graph.
dir | [in] Edge direction. |
def sparksee.SinglePairShortestPathDijkstra.add_edge_type | ( | self, | |
type, | |||
dir | |||
) |
Allows for traversing edges of the given type.
type | [in] Edge type. |
dir | [in] Edge direction. |
def sparksee.SinglePairShortestPathDijkstra.add_node_type | ( | self, | |
type | |||
) |
Allows for traversing nodes of the given type.
type | null |
def sparksee.SinglePairShortestPathDijkstra.add_weighted_edge_type | ( | self, | |
type, | |||
dir, | |||
attr | |||
) |
Allows for traversing edges of the given type using the given attribute as the weight.
type | [in] Edge type. |
dir | [in] Edge direction. |
attr | [in] Attribute to be used as the weight. It must be a global attribute or an attribute of the given edge type. |
|
inherited |
Closes the ShortestPath instance.
It must be called to ensure the integrity of all data.
def sparksee.SinglePairShortestPathDijkstra.exclude_edges | ( | self, | |
edges | |||
) |
Set which edges can't be used.
This will replace any previously specified set of excluded edges. Should only be used to exclude the usage of specific edges from allowed edge types because it's less efficient than not allowing an edge type.
edges | [in] A set of edge identifiers that must be kept intact until the destruction of the class. |
def sparksee.SinglePairShortestPathDijkstra.exclude_nodes | ( | self, | |
nodes | |||
) |
Set which nodes can't be used.
This will replace any previously specified set of excluded nodes. Should only be used to exclude the usage of specific nodes from allowed node types because it's less efficient than not allowing a node type.
nodes | [in] A set of node identifiers that must be kept intact until the destruction of the class. |
def sparksee.SinglePairShortestPathDijkstra.get_cost | ( | self | ) |
Gets the cost of the shortest path.
The cost is the sum of the weights of the edges in the shortest path.
def sparksee.SinglePairShortestPathDijkstra.get_path_as_edges | ( | self | ) |
Gets the shortest path between the source node and the destination node as an ordered set of edges.
def sparksee.SinglePairShortestPathDijkstra.get_path_as_nodes | ( | self | ) |
Gets the shortest path between the source node and the destination node as an ordered set of nodes.
|
inherited |
Gets if ShortestPath has been closed or not.
def sparksee.SinglePairShortestPathDijkstra.set_dynamic_edge_cost_callback | ( | self, | |
dyn_cost_calculator | |||
) |
Set a class callback to dynamically calculate the cost of the edges.
The callback can be set to NULL (the default) to use the normal attribute based cost weights. The given class must be kept alive by the user for as long as the algorithm is running.
dyn_cost_calculator | [in] Class callback to calculate the edge costs |
def sparksee.SinglePairShortestPathDijkstra.set_maximum_hops | ( | self, | |
maxhops | |||
) |
Sets the maximum hops restriction.
All paths longer than the maximum hops restriction will be ignored.
maxhops | [in] The maximum hops restriction. It must be positive or zero. Zero, the default value, means unlimited. |
def sparksee.SinglePairShortestPathDijkstra.set_unweighted_edge_cost | ( | self, | |
weight | |||
) |
Sets the weight assigned to the unweighted edges.
All the edges from the types added without an explicit weight attribute will get this weight. The default weight for this edges is 1.
weight | [in] The weight value for unweighted edges. |