General

Computer Science

  1. 1. Introduction to Computer Science
  2. Legacy Course

  3. Introduction to Computer Science
  4. History of Computer Science
  5. Fundamentals of Computer Science
  6. Algorithms
  7. Data Structures
  8. Programming Concepts
  9. Web Development
  10. Databases and SQL
  11. Networking and Security
  12. Artificial Intelligence and Machine Learning
  13. Mobile App Development
  14. Game Development
  15. Future of Computer Science
  16. Careers in Computer Science

Graph Algorithms

Module Progress
0 / 52 Lessons
0%
Learning

Graph algorithms are methods used to manipulate and analyze the structure of a graph. Three common graph algorithms are breadth-first search, depth-first search, and Dijkstra's algorithm for finding the shortest path.

Breadth-first search (BFS) is an algorithm used to traverse a graph. It starts at a given vertex (node) and explores all of its neighboring vertices before moving on to the next level of vertices. This process continues until all vertices in the graph have been visited. The time complexity of BFS is O(V + E), where V is the number of vertices and E is the number of edges in the graph. BFS is often used to find the shortest path in an unweighted graph.

Depth-first search (DFS) is another algorithm used to traverse a graph. It starts at a given vertex and explores as far as possible along each branch before backtracking. The time complexity of DFS is also O(V + E). DFS is often used to find a path between two vertices or to perform a topological sort of a directed acyclic graph (DAG).

Dijkstra's algorithm is used to find the shortest path between two vertices in a weighted graph. The algorithm starts at the source vertex and assigns a tentative distance to each vertex. The algorithm then selects the vertex with the smallest tentative distance and updates the tentative distance of its neighbors. This process is repeated until the target vertex is reached or all vertices have been visited. The time complexity of Dijkstra's algorithm is O(V2) or O(E + VlogV) using a priority queue.

Continue learning with Knowness

Sign up to access the full lesson, predicted grades, revision tools, progress tracking, and more.

Create a free account