tgraboski / tarjan
A simple cycle-detection algorithm. Given an edge-edges adjacency list, it returns a list of cycles.
Installs: 1 671
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
This package is not auto-updated.
Last update: 2024-12-21 19:58:11 UTC
README
#Tarjan
This is a small script for detecting cycles in a graph.
Input: an array of vertex-children lists: [[1,2,3], [5,6,7]] means vertex 0 points to vertices 1, 2, and 3, while vertex 1 points to vertices 5, 6, and 7.
Output: an array of cycles: [[2,3,5,2], [5,6,5], [3,7,9,3]] contains three cycles. The first goes from 2 to 3 to 5 back to 2.