Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/finanalyst/p6-algorithm-tarjan
perl6 implementation of Tarjan algorithm
https://github.com/finanalyst/p6-algorithm-tarjan
Last synced: 17 days ago
JSON representation
perl6 implementation of Tarjan algorithm
- Host: GitHub
- URL: https://github.com/finanalyst/p6-algorithm-tarjan
- Owner: finanalyst
- License: artistic-2.0
- Created: 2016-05-26T13:13:16.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-10-22T06:34:13.000Z (about 6 years ago)
- Last Synced: 2024-10-08T14:01:24.103Z (about 1 month ago)
- Language: Perl 6
- Homepage:
- Size: 32.2 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# p6-Algorithm-Tarjan
A perl6 implementation of Tarjan's algorithm for finding strongly connected components in a directed graph.
More information can be found at wikipedia.org/wiki/Tarjan's_strongly_connected_components_algorithm.
If there is a cycle, then it will be within a strongly connected component. This implies that the absence of strongly connected components (other than a node with itself) means there are no cycles. It is possible there may be no cycles, but a strongly connected component may still exist (if I have interpreted the theory correctly). I was interested in the absence of cycles.
```
use Algorithm::Tarjan;my Algorithm::Tarjan $a .= new();
my %h;
# code to fill %h node->[successor nodes]$a.init(%h);
say 'There are ' ~ $a.find-cycles() ~ ' cycle(s) in the input graph';
```
If there is a need for the sets of strongly connected components, they can be retrieved from $a.strongly-connected (an array of node names).