Skip to content

PathFinding

Overview

The DijkstraPathFinder class is designed to find the shortest path between two nodes in a graph using Dijkstra's algorithm. This functionality is part of the Euler Graph Database and extends the BasePathFinder class.

Arguments

  • graph (nx.Graph): The graph in which to find the path.
  • start_node (str): The starting node for the path.
  • end_node (str): The ending node for the path.

Example Usage

Here's an example demonstrating how to use the DijkstraPathFinder class:

from euler.path_finding.dijkstra_pathfinder import DijkstraPathFinder

Initialize the Knowledge Graph

graph = euler_graph.graph.to_networkx()

Find the Path Using Dijkstra's Algorithm

path_finder = DijkstraPathFinder(graph, start_node='1', end_node='4')
print(f"Path: {path_finder.find_path().path}")

Functions

PathFinderConfig

The PathFinderConfig class is a configuration model that defines the structure of the graph, start node, and end node.

PathResponse

The PathResponse class is a model that defines the structure of the response, including the path found.

DijkstraPathFinder

The DijkstraPathFinder class uses Dijkstra's algorithm to find the shortest path between the start node and the end node in the given graph. It returns a PathResponse object containing the path.

This documentation provides an overview, argument details, and a complete example of how to use the DijkstraPathFinder class for finding the shortest path in a graph using Dijkstra's algorithm.