haskell / haskell/fgl

gsel ignores edges to nodes

Open
#89 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
200
Forks
58
PR merge metrics
No merged PRs in 30d

Description

Hello!

I tried to use `gsel` to find "start nodes", i.e. nodes to which have no edges point.
However, `gsel` seems to treat all "Contexts" as if no edges point to the node:

```
import qualified Data.Graph.Inductive as Gr

-- use gsel to select start nodes:
startNodes :: Gr.Gr n e -> [Gr.Context n e]
startNodes =
Gr.gsel $ \x -> case x of
([], _node, _, _outEdges) -> True
_ -> False

-- example graph:
test :: Gr.Gr String ()
test =
Gr.mkGraph
(zip [0..] ["a", "b", "c","d"])
[(0,1,()),(0,2,()),(1,3,()),(2,3,())]
```

now, in ghci:
```
$ > Gr.prettyPrint test
0:"a"->[((),1),((),2)]
1:"b"->[((),3)]
2:"c"->[((),3)]
3:"d"->[]
$ > startNodes test
[([],0,"a",[((),1),((),2)]),([],1,"b",[((),3)]),([],2,"c",[((),3)]),([],3,"d",[])]
```
(gsel selects all nodes)

expected result: `[([],0,"a",[((),1),((),2)])]`
(only node 0 should be selected)

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the reported behavior in ghci using the provided test graph, startNodes definition, and Gr.prettyPrint output. Inspect the gsel entry point and how it supplies Context values to the predicate; done means gsel distinguishes incoming edges and returns only node 0 for this example.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.