Skip to content

Add examples for custom graph in the doc of soft_random_geometric_graph and thresholded_random_geometric_graph - #7749

Merged
Schefflera-Arboricola merged 4 commits into
networkx:mainfrom
yuanx749:custom-graph
Dec 5, 2024
Merged

Schefflera-Arboricola merged 4 commits into
networkx:mainfrom
yuanx749:custom-graph

Conversation

@yuanx749

Copy link
Copy Markdown
Contributor

Refer to #7730 (comment).

This PR added example code following the corresponding instructions of Custom Graph in the docstrings. Also correct the link of scipy.stats, which directed to 404 not found before.

Comment thread networkx/generators/geometric.py Outdated
>>> n = 100
>>> p_dist = lambda x: expon.pdf(x, scale=1)
>>> G = nx.soft_random_geometric_graph(n, 0.2, p_dist=p_dist)

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.

Thanks for adding this @yuanx749 ! If possible, please consider moving the example(explaining the usage of pos kwarg) from the Notes section to this Example section. And the whole Example section at the end(https://numpydoc.readthedocs.io/en/latest/format.html#examples). Thanks!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your review and addressing the CI failure. @Schefflera-Arboricola . I've made the move, with wording slightly adjusted.

Comment thread networkx/generators/geometric.py Outdated
>>> n = 50
>>> weight = {i: random.expovariate(5) for i in range(n)}
>>> G = nx.thresholded_random_geometric_graph(n, 0.2, 0.1, weight=weight)

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.

same here.

@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 replacing the scipy reference (i.e. .. [2]) with intersphinx links, other than that LGTM, thanks @yuanx749 !

@Schefflera-Arboricola
Schefflera-Arboricola merged commit 32c898d into networkx:main Dec 5, 2024
@jarrodmillman jarrodmillman added this to the 3.5 milestone Dec 5, 2024
@yuanx749
yuanx749 deleted the custom-graph branch December 6, 2024 01:13
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