Skip to content

IndexError in consolidate function #7

Open
@MartinKern

Description

@MartinKern

In some cases there will be an IndexError in the consolidate function in line 122:
A = [None] * int(math.log(self.total_nodes) * 2)
int(math.log(self.total_nodes) * 2) is supposed to be the maximum number of distinct node degrees. This is however off by one and a bit. The node degree d is bound by where is the golden ratio (See Wikipedia). Doing the math I got . So the 2 needs to be replaced with something like 2.08. The number of possible distinct node degrees is one higher than this since nodes with a degree of zero need to be considered. The solution is to replace:
A = [None] * int(math.log(self.total_nodes) * 2)
with
A = [None] * int(math.log(self.total_nodes) * 2.08 + 1)

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