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

Adding vertex plotting option to plot_network #390

Closed
wants to merge 7 commits into from

Conversation

kbonney
Copy link
Collaborator

@kbonney kbonney commented Nov 6, 2023

Provide a summary of the proposed changes, describe tests and documentation, and review the acknowledgement below.

Summary

This PR adds the ability to plot vertices to the plot_network function.

Tests and documentation

Below are comparisons of the graphics generated in the current tests by plot_network with the same graphics generated with plot_vertices=True to verify that the updates don't break current behavior. Note, these don't actually plot any vertices because the involved networks don't have any.:

  • test_plot_network1
    image
  • test_plot_network2
    image
  • test_plot_network3
    image
  • test_plot_network4
    image
  • test_plot_network5
    image

A new test using io.inp is added to verify a network that actually have vertices:
image

TODO

  • decide whether to make plot vertices default behavior or leave it as an optional argument.

Acknowledgement

By contributing to this software project, I acknowledge that I have reviewed the software quality assurance guidelines and that my contributions are submitted under the Revised BSD License.

@kbonney
Copy link
Collaborator Author

kbonney commented Nov 7, 2023

  • Test computational load on large networks
  • see if vertex graph generation could be moved to to_graph()

vertices = link.vertices
if include_vertices and vertices:
node_base_name = name + "_vertex_"
link_base_name = name + "_vertexlink_"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

vertexlink -> vertex

nx.set_edge_attributes(G, name="base_link", values={(start_node, end_node, link_name): link.name})
nx.set_node_attributes(G, name="pos", values={end_node: vertices[vertex_ind]})
nx.set_node_attributes(G, name="type", values={end_node: "Vertex"})
nx.set_node_attributes(G, name="base_link", values={end_node: link.name})
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

base_link -> link_name

@@ -43,7 +43,7 @@ def _format_link_attribute(link_attribute, wn):

return link_attribute

def plot_network(wn, node_attribute=None, link_attribute=None, title=None,
def plot_network(wn, node_attribute=None, link_attribute=None, title=None, plot_vertices=False,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

plot_vertices -> include_vertices

@kbonney
Copy link
Collaborator Author

kbonney commented Oct 3, 2024

Closing in favor of #451

@kbonney kbonney closed this Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant