I think that depth first search solves it. If an unexplored edge leads to a node visited before, then the graph contains a cycle. This condition also makes it O(n), since you can explore maximum n edges without setting it to true or being left with no unexplored edges.
More Related Contents:
- Finding connected components of adjacency matrix graph
- Best algorithm for detecting cycles in a directed graph [closed]
- Finding all cycles in a directed graph
- Graph Algorithm To Find All Connections Between Two Arbitrary Vertices
- Find all paths between two graph nodes
- Why doesn’t Dijkstra’s algorithm work for negative weight edges?
- Find the shortest path in a graph which visits certain nodes
- Compute the minimal number of swaps to order a sequence
- Graph auto-layout algorithm
- Find connected components in a graph [closed]
- Find the paths between two given nodes?
- Finding all the shortest paths between two nodes in unweighted undirected graph
- What are the practical factors to consider when choosing between Depth-First Search (DFS) and Breadth-First Search (BFS)? [closed]
- How to implement depth first search for graph with a non-recursive approach
- help in the Donalds B. Johnson’s algorithm, i cannot understand the pseudo code (PART II)
- Why is the time complexity of both DFS and BFS O( V + E )
- Why use Dijkstra’s Algorithm if Breadth First Search (BFS) can do the same thing faster?
- What algorithm to use to determine minimum number of actions required to get the system to “Zero” state?
- Enumerating all paths in a directed acyclic graph
- How does Dijkstra’s Algorithm and A-Star compare?
- Why DFS and not BFS for finding cycle in graphs
- Find cycle of shortest length in a directed graph with positive weights
- graph – Dijkstra for The Single-Source Longest Path
- Algorithm to simplify a weighted directed graph of debts
- Number of paths between two nodes in a DAG
- Planar Graph Layouts
- Explanation of Algorithm for finding articulation points or cut vertices of a graph
- Bridges in a connected graph
- How to find the number of different shortest paths between two vertices, in directed graph and with linear-time?
- Complete graph with only two possible costs. What’s the shortest path’s cost from 0 to N – 1