graphalgo.rst 1.1 KB

1234567891011121314151617181920212223242526
  1. :mod:`altgraph.GraphAlgo` --- Graph algorithms
  2. ==================================================
  3. .. module:: altgraph.GraphAlgo
  4. :synopsis: Basic graphs algoritms
  5. .. function:: dijkstra(graph, start[, end])
  6. Dijkstra's algorithm for shortest paths.
  7. Find shortest paths from the start node to all nodes nearer
  8. than or equal to the *end* node. The edge data is assumed to be the edge length.
  9. .. note::
  10. Dijkstra's algorithm is only guaranteed to work correctly when all edge lengths are positive.
  11. This code does not verify this property for all edges (only the edges examined until the end
  12. vertex is reached), but will correctly compute shortest paths even for some graphs with negative
  13. edges, and will raise an exception if it discovers that a negative edge has caused it to make a mistake.
  14. .. function:: shortest_path(graph, start, end)
  15. Find a single shortest path from the given start node to the given end node.
  16. The input has the same conventions as :func:`dijkstra`. The output is a list
  17. of the nodes in order along the shortest path.