Pathing#
- raphtory.algorithms.temporally_reachable_nodes(g, max_hops, start_time, seed_nodes, stop_nodes=None)#
Temporally reachable nodes – the nodes that are reachable by a time respecting path followed out from a set of seed nodes at a starting time.
This function starts at a set of seed nodes and follows all time respecting paths until either a) a maximum number of hops is reached, b) one of a set of stop nodes is reached, or c) no further time respecting edges exist. A time respecting path is a sequence of nodes v_1, v_2, … , v_k such that there exists a sequence of edges (v_i, v_i+1, t_i) with t_i < t_i+1 for i = 1, … , k - 1.
- Parameters:
g (GraphView) – directed Raphtory graph
max_hops (int) – maximum number of hops to propagate out
start_time (int) – time at which to start the path (such that t_1 > start_time for any path starting from these seed nodes)
seed_nodes (list[InputNode]) – list of node names or ids which should be the starting nodes
stop_nodes (Optional[list[InputNode]]) – nodes at which a path shouldn’t go any further
- Returns:
AlgorithmResult with string keys and float values mapping node names to their pagerank value.
- Return type:
- raphtory.algorithms.single_source_shortest_path(g, source, cutoff=None)#
Calculates the single source shortest paths from a given source node.
- Parameters:
g (GraphView) – A reference to the graph. Must implement GraphViewOps.
source (InputNode) – The source node. Must implement InputNode.
cutoff (int, optional) – An optional cutoff level. The algorithm will stop if this level is reached.
- Returns:
Returns an AlgorithmResult[str, list[str]] containing the shortest paths from the source to all reachable nodes.
- Return type:
- raphtory.algorithms.dijkstra_single_source_shortest_paths(g, source, targets, direction=..., weight=...)#
Finds the shortest paths from a single source to multiple targets in a graph.
- Parameters:
g (GraphView) – The graph to search in.
source (InputNode) – The source node.
targets (list[InputNode]) – A list of target nodes.
direction (Direction) – The direction of the edges to be considered for the shortest path. Defaults to “both”.
weight (str) – The name of the weight property for the edges. Defaults to “weight”.
- Returns:
Returns a Dict where the key is the target node and the value is a tuple containing the total cost and a vector of nodes representing the shortest path.
- Return type:
dict