Graph


  1. Bellman–Ford algorithm

    Bellman-Ford can handle graphs with negative edge weights, unlike Dijkstra's algorithm. It has a time complexity of O(V * E), where V is the number of vertices and E is the number of edges.

  2. Breadth-first search

    Given an adjacency-list representation of a graph and a starting vertex, visit and print every reachable vertex in breadth-first order.

  3. Depth-first search

    Given an adjacency-list representation of a graph and a starting vertex, visit and print every reachable vertex in depth-first order.

  4. Dijkstra's algorithm

    Given a weighted graph, a source and a destination vertices in the graph, find the shortest paths from the source to the destination vertices in the given graph.

  5. Edmonds-Karp maximum flow

    Given a directed capacity graph, a source vertex, and a sink vertex, find the maximum flow from the source to the sink using breadth-first search to select augmenting paths.

  6. Floyd Warshall algorithm

    Floyd-Warshall efficiently finds the shortest paths between all pairs of vertices in a graph. Handles graphs with negative edge weights, but it cannot detect negative cycles.

  7. Ford-Fulkerson maximum flow

    Given a directed capacity graph, a source vertex, and a sink vertex, find the maximum flow from the source to the sink.

  8. Kruskal's minimum spanning tree

    Given a weighted, undirected graph as an edge list and the number of vertices, find a minimum spanning tree without creating cycles.

  9. Prim's minimum spanning tree

    Given a connected, weighted, undirected graph represented by an adjacency matrix, find a minimum spanning tree starting from vertex 0 and return its selected edges.

  10. Find shortest path in an unweighted graph

    Given list of edges, find shortest path from source node to destination node in an unweighted graph.