You can implement networkx. Here’s a recent example:
networkx
Or implement e.g. Dijkstra’s shortest path natively. Example here: