.. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_plot_dominators.py: Grave Documentation ------------------- .. image:: /gallery/images/sphx_glr_plot_dominators_001.png :class: sphx-glr-single-img .. code-block:: python import networkx as nx from networkx.algorithms.approximation.dominating_set import min_weighted_dominating_set import matplotlib.pyplot as plt from grave import plot_network, use_attributes toy_network = nx.barbell_graph(10, 14) dom_set = min_weighted_dominating_set(toy_network) for node, node_attrs in toy_network.nodes(data=True): if node in dom_set: node_attrs['color'] = 'red' else: node_attrs['color'] = 'black' node_attrs['size'] = 50 fig, ax = plt.subplots() plot_network(toy_network, node_style=use_attributes()) plt.show() **Total running time of the script:** ( 0 minutes 0.043 seconds) .. _sphx_glr_download_gallery_plot_dominators.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download :download:`Download Python source code: plot_dominators.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: plot_dominators.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_