Skip to content

Bug in BFS? #2

Open
Open
@apeano

Description

@apeano

Hello,
it seems that the procedure never enters in the "allowTraversal" function. Thus, it loops forever in case of graphs with cycles.

I don't know very well PowerShell, however from a first insight it is weird that the $seen variable is initialized every time allowTraversal is called.

I used this patch:
$graph.getNeighbors($currentVertex).ForEach{ $nextVertex = $_ if (!$seen[$nextVertex.getKey()]) { "NOT SEEN: " + $nextVertex.getKey() $seen[$nextVertex.getKey()] = $true $vertexQueue.enqueue($nextVertex) } }

Cheers

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions