elm-community / graph

Functional Graph Library in Elm.

Home Page:http://package.elm-lang.org/packages/elm-community/graph/latest

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

stronglyConnectedComponents does not detect self-loops

DavidDTA opened this issue · comments

Currently it checks that a graph is acyclic by looking at whether all components have a size of 1. However, this does not account for self-loops, which should count as cycles. I would expect that a graph with a self loop would return Err, even if all components have a size of 1. Specifically, I would expect stronglyConnectedComponents to return Err if and only if checkAcyclic does.

https://ellie-app.com/ksT33qbjGa1/1

Right, that's quite a bug! Should be fixed by 8f9aa6b. Will be published as v4.0.1 when CI is green.

I think the documentation needs to be updated as well. Currently it says

Err components means there were cycles in the graph and as such there is at least one non-singleton connected component in components.

I may be misinterpreting singleton, but it sounds like it means a graph with more than one node.