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

CNFG Link Prediction Algorithm Implementation #4423

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

cgalo
Copy link

@cgalo cgalo commented Dec 5, 2020

Hello!

As part of my course project for Social & Information Networks at the University of Toledo, me and @yashwalankar, focused on implementing the CNGF link prediction algorithm[1]. This algorithm was proposed due to the lack of link prediction algorithms utilizing network topology sufficiently to design the similarity function between entities.

Pseudocode[1]

image

This is the first time I'm contributing to an open-source project, any feedback regarding the implementation, functionality, or documentation will be appreciated!

Reference

[1] Liyan Dong, Yongli Li, Han Yin, Huang Le, Mao Rui, "The Algorithm of Link Prediction on Social Network", Mathematical Problems in Engineering, vol. 2013, Article ID 125123, 7 pages, 2013. https://doi.org/10.1155/2013/125123

cgalo and others added 7 commits November 12, 2020 02:00
Added directory created for development environment
Overview:
- Implemented base version the CNGF algorithm
Updated to note that the algorithm is not implemented for either multigraph nor directed graphs
- Updated function for the CNGF function
- Added testing function for the CNGF implementation
went through all common neighbbors instead of just nodes
Update link_prediction.py for implementation of CNGF
- Updated the implementation of the cngf inside the link_prediction.py
- Updated test cases inside the test_link_prediction.py
- Added documentation for the cngf algorithm. This includes, but is not limited, to the parameters of the function, explanation of the algorithm, example, and reference to the original research paper
@dschult
Copy link
Member

dschult commented Dec 5, 2020

Very interesting -- thanks for this.

Could you make the doc_string better, especially as regards the paragraph after the intro line?
For example, what does CNGF stand for? and why is guidance named that? is it guiding something?
Also, the math can be typeset similar to the function two up from yours in the file.
The reference should have lines indented to match the first (see the function just above yours in the file).

A hook for this function should be added to the doc/reference/algorithms section to make this appear in the full docs reference section.

Setting up subG could avoid all those set commands via subG = G.subgraph(cnbors | {u, v}) and I don't think you need the copy because you don't change subG.

For performance and readability you should avoid creating x_sub_degree and just put subG.degree(x) in the formula.
Perhaps more importantly, since you only look up one node's degree at a time, it is faster to use G.degree[n] than G.degree(n). And I don't think cnbors can ever be None so the if statement is not needed.
Also, the summation for similarity can use Python's more simple sum function:
sum(guidance(node) for node in cnbors)
It even works when cnbors is empty.

Thanks!

Base automatically changed from master to main March 4, 2021 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants