Skip to content

gsel ignores edges to nodes #89

@EsGeh

Description

@EsGeh

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions