Skip to content

trust rank implementation and testing - #8165

Merged
dschult merged 15 commits into
networkx:mainfrom
dean985:trust-rank-8163
Aug 17, 2025
Merged

dschult merged 15 commits into
networkx:mainfrom
dean985:trust-rank-8163

Conversation

@dean985

@dean985 dean985 commented Jul 26, 2025

Copy link
Copy Markdown
Contributor

after viewing discussion:
#8163

i have implemented trust rank algorithm using the existing page rank algorithm.

@amcandio amcandio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments but I'm not super convinced we should add a new method here. I'd prefer if we update pagerank docs talking about how to generate trustrank. Others might feel differently

@rossbar rossbar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm very much in agreement with @amcandio - this is essentially just making use of the personalization feature. I vastly prefer to call this out in the docs rather than add a new function name - I suspect it's one of the main motivations for the personalization feature in the first place.

My vote would be to add a gallery example and/or update the pagerank docstring to make mention of how the personalization feature can be used to get the "trustrank". IMO a gallery example in the "algorithms" section is ideal as it handles the discoverability issue from a search engine perspective.

@dean985

dean985 commented Jul 30, 2025

Copy link
Copy Markdown
Contributor Author

@rossbar @amcandio
Thanks for the feedback and direction. I'd be happy to pivot this PR to create a gallery example.

Could you point me to a good existing gallery example I can use as a template for the format and structure? Thanks

@dschult

dschult commented Jul 30, 2025

Copy link
Copy Markdown
Member

One reasonably simple gallery example to work from would be examples/algorithms/plot_davis_club.py

@rossbar

rossbar commented Jul 30, 2025

Copy link
Copy Markdown
Contributor

Could you point me to a good existing gallery example I can use as a template for the format and structure? Thanks

I agree with @dschult , the Davis club example is a good starting point. I also agree that the Algorithms section is the correct place for a trust rank example.

There is additional information in the contributor guide related to adding gallery examples that may also prove useful!

@dean985

dean985 commented Aug 1, 2025

Copy link
Copy Markdown
Contributor Author

thanks @dschult and @rossbar , i tried to make the code as simple as possible, but with decent documentation. please let me know your comments

Comment thread examples/algorithms/plot_trust_rank.py Outdated
Comment on lines +16 to +20
Key Steps:
1. Define a set of seed nodes that are considered trustworthy.
2. Create a personalization vector where seed nodes are assigned equal trust,
and non-seed nodes are assigned zero.
3. Run the PageRank algorithm with the personalization vector to compute trust scores for all nodes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to render as a list in the docs (can look by clicking on the CI test results for the documentation artifact circle_ci test. Then navigate to the page you want to look at).

I think it is just a matter of a blank line after the line with the colon and probably an indentation of those 3 items as well.

@rossbar rossbar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took the liberty of pushing up a few formatting fixes and adding a seed to the layout for reproducibility. I have a few other minor suggestions for the text but none of them are blockers. Thanks @dean985 !

Comment thread examples/algorithms/plot_trust_rank.py Resolved
Comment thread examples/algorithms/plot_trust_rank.py Outdated
Comment on lines +23 to +30
References
----------
.. [1] Gyongyi, Zoltan; Garcia-Molina, Hector (2004).
"Combating Web Spam with TrustRank"
http://ilpubs.stanford.edu:8090/770/1/2004-52.pdf
.. [2] Krishnan, Vijay; Raj, Rashmi
"Web Spam Detection with Anti-Trust Rank"
http://i.stanford.edu/~kvijay/krishnan-raj-airweb06.pdf

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These seem to deal with applications of trustrank rather than the algorithm itself. Personally I'd prefer to delete the references section and instead turn the first instance of TrustRank into a link to the wiki article (see above suggestions for how to do so).

Comment thread examples/algorithms/plot_trust_rank.py Resolved
Comment thread examples/algorithms/plot_trust_rank.py Resolved
@dean985

dean985 commented Aug 7, 2025 •

Copy link
Copy Markdown
Contributor Author

I took the liberty of pushing up a few formatting fixes and adding a seed to the layout for reproducibility. I have a few other minor suggestions for the text but none of them are blockers. Thanks @dean985 !

Thanks @rossbar for the feedback and changes! Is there anything else needed to move forward with merging?

@rossbar

rossbar commented Aug 13, 2025

Copy link
Copy Markdown
Contributor

Thanks @rossbar for the feedback and changes! Is there anything else needed to move forward with merging?

I left a few suggestions above which, if you agree, you can accept using the add suggestions to batch button; or you can modify/comment as you see fit. If you have no objections to the suggestions I've left I'm happy to just push those up too if it's easier, just LMK!

@dean985

dean985 commented Aug 15, 2025

Copy link
Copy Markdown
Contributor Author

Hey @rossbar, I have no objections to your suggestions, please feel free to push them directly

@rossbar rossbar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dean985 , this LGTM! In principle we could think of adding the "unpersonalized" pagerank results here for comparison but we can always tweak/improve examples in follow-up PRs.

@dschult dschult left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrapped the lines in the doc_string to ~80 chars.
This all looks good. Thanks @dean985!

@dschult
dschult merged commit c5f4646 into networkx:main Aug 17, 2025
alfred-mikhael pushed a commit to alfred-mikhael/networkx that referenced this pull request Sep 3, 2025
* trust rank implementation and testing

* added references

* organizied imports

* linting

* docs, different weights truted nodes

* added trust rank plot example instead of implementation

* linting

* linting, comment editing

* Formatting fixups, seed layout.

* Apply suggestions from code review

Co-authored-by: Ross Barnowski <[email protected]>

* Replace references with wiki link.

* wrap doc lines

---------

Co-authored-by: Ross Barnowski <[email protected]>
Co-authored-by: Dan Schult <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants