.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "sphinx_gallery_output/plot_15_highlight_paths.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_sphinx_gallery_output_plot_15_highlight_paths.py: Highlight paths =============== .. GENERATED FROM PYTHON SOURCE LINES 7-41 .. image-sg:: /sphinx_gallery_output/images/sphx_glr_plot_15_highlight_paths_001.png :alt: plot 15 highlight paths :srcset: /sphinx_gallery_output/images/sphx_glr_plot_15_highlight_paths_001.png :class: sphx-glr-single-img .. code-block:: default import matplotlib.pyplot as plt import networkx as nx from netgraph import Graph # create a random geometric graph and plot it g = nx.random_geometric_graph(100, 0.15, seed=42) node_positions = nx.get_node_attributes(g, 'pos') plot_instance = Graph(g, node_layout=node_positions, node_size=1, node_edge_width=0.1, edge_width=0.1) # select a random path in the network and plot it path = nx.shortest_path(g, 33, 66) for node in path: plot_instance.node_artists[node].radius = 1.5 * 1e-2 plot_instance.node_artists[node].set_color('orange') for ii, node_1 in enumerate(path[:-1]): node_2 = path[ii+1] if (node_1, node_2) in plot_instance.edges: edge = (node_1, node_2) else: # the edge is specified in reverse node order edge = (node_2, node_1) plot_instance.edge_artists[edge].update_width(0.5 * 1e-2) plot_instance.edge_artists[edge].set_color('red') plot_instance.edge_artists[edge].set_alpha(1.0) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.680 seconds) .. _sphx_glr_download_sphinx_gallery_output_plot_15_highlight_paths.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_15_highlight_paths.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_15_highlight_paths.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_