Skip to content

Commit f3fd195

Browse files
committed
feat: add graph algorithem
1 parent 0b08df4 commit f3fd195

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pydatastructs/graphs/algorithms.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -723,10 +723,10 @@ def shortest_paths(graph: Graph, algorithm: str, source: str, target: str="", **
723723
shortest_paths, kwargs.get('backend', Backend.PYTHON))
724724
import pydatastructs.graphs.algorithms as algorithms
725725
func = "_" + algorithm + "_" + graph._impl
726+
if algorithm not in ['bellman_ford', 'dijkstra', 'A_star']:
727+
raise NotImplementedError(f"Algorithm {algorithm} is not implemented.")
726728
if not hasattr(algorithms, func):
727-
raise NotImplementedError(
728-
"Currently %s algorithm isn't implemented for "
729-
"finding shortest paths in graphs."%(algorithm))
729+
raise NotImplementedError(f"Currently {algorithm} algorithm isn't implemented for finding shortest paths in graphs.")
730730
return getattr(algorithms, func)(graph, source, target)
731731

732732
def _bellman_ford_adjacency_list(graph: Graph, source: str, target: str) -> tuple:

0 commit comments

Comments
 (0)