Skip to content

Improve efficiency of edgeIndices function #1

@ianmackenzie

Description

@ianmackenzie

Currently a Set ( Int, Int ) is used to track unique edges, but this involves allocating (and comparing) a lot of tuples. Instead, build up a Set Int where each Int is a packed edge index equal to

lowerVertexIndex * numVertices + higherVertexIndex

Then, once that set is constructed, use Set.foldr to iterate through the set, unpack each Int back into an ( Int, Int ) using mod and //, and accumulate these values into a list. This should maintain the property that edges are returned in sorted order with lower vertex index first and higher vertex index second.

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