Repository navigation
Cache edges, degree, adj properties of Graph classes - #5614
Merged
Merged
Conversation
jarrodmillman
approved these changes
May 11, 2022
Contributor
|
@dschult Just double checking: I assumed when I made my original PR that the AdjacencyViews update themselves dynamically (they are called views, after all!). Is that assumption correct? |
Member
Author
|
Yes, that is correct. The Views point to the graph data structures directly to report their information. That means you are safe unless you e.g. replace the dict |
Contributor
|
Thanks @dschult! |
MridulS
pushed a commit
to MridulS/networkx
that referenced
this pull request
Feb 4, 2023
* Make all graph properties cached properties * one test function is not needed due to test inheritance
cvanelteren
pushed a commit
to cvanelteren/networkx
that referenced
this pull request
Apr 22, 2024
* Make all graph properties cached properties * one test function is not needed due to test inheritance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use cached_property for caching the view properties of graph classes (not
G.namewhich can be changed and thus should be a regular non-cached property).The changed properties include: G.edges, G.degree, G.adj (and G.in_edges, G.out_edges, G.in_degree, G.out_degree, G.pred, G.succ). Added tests that multiple calls return the same object (caching is successful).
Changes to Graph, DiGraph, MultiGraph, MultiDiGraph and AntiGraph. Also reportviews.py had to change one
__setstate__function.