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 (Raphtory graph) – 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(str) or list(int)) – list of node names or ids which should be the starting nodes
stop_nodes (list(str) or list(int)) – 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 (Raphtory Graph) – 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<String, Vec<String>> containing the shortest paths from the source to all reachable nodes.
- raphtory.algorithms.dijkstra_single_source_shortest_paths(g, source, targets, weight=...)#
Finds the shortest paths from a single source to multiple targets in a graph.
- Parameters:
g (Raphtory Graph) – The graph to search in.
source (InputNode) – The source node.
targets (List(InputNodes)) – A list of target nodes.
weight (String, Optional) – The name of the weight property for the edges (“weight” is default).
- 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.