NextAlgoLabs
HomeAboutCategoriesBlogContact
Categories
Graph Algorithms

Graph Algorithms

Explore graph traversal, shortest path, and network flow algorithms

Breadth-First Search

Breadth-First Search (BFS) is a graph traversal algorithm that explores all vertices at the current depth level before moving to vertices at the next depth level. It uses a queue data structure and is useful for finding shortest paths in unweighted graphs.

Time: O(V + E)
Space: O(V)

Depth-First Search

Depth-First Search (DFS) is a graph traversal algorithm that explores as far as possible along each branch before backtracking. It uses a stack (or recursion) and is useful for topological sorting, detecting cycles, and solving maze problems.

Time: O(V + E)
Space: O(V)

Dijkstra's Algorithm

Dijkstra's algorithm finds the shortest path from a source vertex to all other vertices in a weighted graph with non-negative edge weights. It uses a priority queue and is widely used in routing and network protocols.

Time: O((V + E) log V)
Space: O(V)

A* Algorithm

A* is an informed search algorithm that finds the shortest path using both the actual distance from the start and an estimated distance to the goal (heuristic). It's optimal and efficient for pathfinding in games and robotics.

Time: O(b^d)
Space: O(b^d)

Topological Sort

Topological sort orders the vertices of a directed acyclic graph (DAG) such that for every directed edge (u, v), u comes before v. It's used in task scheduling, build systems, and dependency resolution.

Time: O(V + E)
Space: O(V)
NextAlgoLabs

Learn algorithms through interactive visualizations

Platform

  • Categories
  • About
  • Blog

Resources

  • Contact

Legal

  • Privacy Policy
  • Terms of Service

© 2026 NextAlgoLabs. All rights reserved.