aws-samples / amazon-braket-community-detection

Community detection in complex networks using hybrid quantum annealing on Amazon Braket
MIT No Attribution
12 stars 7 forks source link

Facing Node without community assignment! or Multi-community assignment! Error #1

Closed lighterRS232 closed 2 years ago

lighterRS232 commented 2 years ago

Hello, the examples provided are working only if we set k = 2 otherwise it throws an exception with Multi-community assignment! or Node without community assignment! error.

Any suggestion to overcome this problem?

jzhzhu commented 2 years ago

Which graph are you testing and throws errors? For multi-community assignment issue, you can increase 'alpha' to 10 or 20 range (theoretically no up limit). Alpha is the penalty term coefficient that forces one community assignment only per node. For node without community issue, did you check the node degree of your graph? You need to make sure the node degree >= 1, otherwise nodes with degree=0 won't have community assigned, and you should remove those zero-degree nodes from the graph for community detection purpose.

lighterRS232 commented 2 years ago

Thank you for your answer! I've started with my own graph but, just to be sure, I've fallen back with Zachary karate Club graph (using networkX embedded) and I saw that the problem persist. Only if I set k = 2 seem that all the things work properly.

Already tried to increase alpha but the error persist :/

jzhzhu commented 2 years ago

if you re-clone the repo and run the notebook, will it still give your error? I cannot reproduce the error from my end, and will need more information to help debug.

A side note: if you use your own graph, please make sure the nodes are indexed from 0, seen in the function of def _sort_nodes(nx_G) in script src/graph_community.py

lighterRS232 commented 2 years ago

I've recloned the repo, generated a new workspace with a dedicated venv to avoid any possible problems and executed the notebook Notebook_QBSolv_community_detection.ipynb without doing any changes:

one

But, sadly, it returns me the error

two

Could be related to the fact that the requirements.txt file doesn't have the dependencies pinned and something, underlying, is messing up with all the dependencies to the latest versions?

anoir2 commented 2 years ago

Hello! This morning I've done some debugging by analyzing the version stuff that I've said yesterday and... BINGO! There are some problems with the latest version of the packages that the application is using. I've pinned all the dependencies with the versions available before the article publishing date, installed and executed in a venv and now all seems working properly.

Should I open a PR?

Here there are the pinned versions:

networkx==2.6.3
scipy==1.7.2
pandas==1.3.4
matplotlib==3.4.3
minorminer==0.2.6
amazon-braket-sdk==1.9.5
dwave-ocean-sdk==4.2.0
amazon-braket-ocean-plugin==1.0.6
anoir2 commented 2 years ago

However, I think that these bugs need further investigation, in order to check if there are some bugs in the SDK.

PS I'm lighterRS232, yesterday had some problems accessing my main account.

jzhzhu commented 2 years ago

Thanks for the finding and the PR. I agree these errors are due to misaligned python package versions. We will investigate further on the versioning impact, including the NetworkX 3.0 change on the adjacency matrix format.

Do you happen to have a view of the python package versions that gave the errors? Can you share them here? Thanks!

anoir2 commented 2 years ago

I'll do some further diagnostics when in the next few days and I will post more details about it if I have it.

Thanks a lot for the support, you were so gentle!

jzhzhu commented 2 years ago

Thank you. I close the issue for now. Please feel free to post if you find more details.