Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'NoneType' object has no attribute 'data' #4

Open
mshishvan opened this issue Aug 24, 2018 · 2 comments
Open

AttributeError: 'NoneType' object has no attribute 'data' #4

mshishvan opened this issue Aug 24, 2018 · 2 comments

Comments

@mshishvan
Copy link

Hi Daniel,

I tried to test the algorithm with some different numbers, I faced the "AttributeError: 'NoneType' object has no attribute 'data'". basically, when you have many same key nodes, this error happens. Do you maybe know why this is happening? (It removes the node from child list other than the rootlist.)

https://repl.it/Bouq/13

f = FibonacciHeap()
seed(4333)
# insert elements
for i in xrange(0, 1000): #tried to do for 1000 nodes
    f.insert(randint(1,500)) #random number between 1-500
    
# print the root list
print [x.data for x in f.iterate(f.root_list)]

# extract min
while f.total_nodes > 0:
    m = f.extract_min()
    print 'min is: ' + str(m.data)

@c752334430
Copy link

@mshishvan Hi I know it's kind of late to say this, but I found out the bug comes out because min_node can points to a child node not in the rootlist after consolidate when have several nodes with same key. Change "if A[i].key < self.min_node.key:" to "if A[i].key <= self.min_node.key:" in the consolidate function will solve this.

@bilzard bilzard mentioned this issue Dec 12, 2021
@bilzard
Copy link

bilzard commented Dec 12, 2021

I sent PR #10 fo fix this issue please review it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants