Acyclic Graph is a directed graph with no cycles (DAG). It is widely used in scheduling, dependency resolution, and more.
Key Characteristics:
Directed Graph: A graph where each edge has a direction, going from one node (the source) to another node (the target). In a directed graph, the edge (A → B) is not the same as (B → A). This allows us to represent dependencies and flows.
Topological Sort: An ordering of the nodes in a directed acyclic graph (DAG) such that for every directed edge (U → V), node U comes before node V in the ordering. Topological sort is useful for scheduling tasks, resolving dependencies, and more. Only possible if the graph has no cycles.
Strengths:
Limitations:
| Operation | Time Complexity | Space Complexity |
|---|---|---|
| Add Node | O(1) | O(1) |
| Add Edge | O(1) | O(1) |
| Remove Node | O(V+E) | O(1) |
| Remove Edge | O(1) | O(1) |
| Topological Sort | O(V+E) | O(V+E) |
| Cycle Check | O(V+E) | O(V+E) |