.. _sphx_glr_gallery_plot_dominators.py: GraVE Documentation ------------------- .. image:: /gallery/images/sphx_glr_plot_dominators_001.png :align: center .. 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.182 seconds) .. only :: html .. container:: sphx-glr-footer .. 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 `_