.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/basic/plot_dag.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_basic_plot_dag.py: Directed Acyclic Graph ====================== This example demonstrates how to create a random directed acyclic graph (DAG) and how to use `igraph` layouts based on strings. .. GENERATED FROM PYTHON SOURCE LINES 7-37 .. image-sg:: /gallery/basic/images/sphx_glr_plot_dag_001.png :alt: plot dag :srcset: /gallery/basic/images/sphx_glr_plot_dag_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none [] | .. code-block:: Python import random import igraph as ig import iplotx as ipx # First, we set a random seed for reproducibility. random.seed(0) # We generate a random undirected graph with a fixed number of edges, without loops. g = ig.Graph.Erdos_Renyi(n=15, m=30, directed=False, loops=False) # Then we convert it to a DAG *in place* and replot it: g.to_directed(mode="acyclic") ipx.plot( g, layout="sugiyama", style={ "vertex": { "size": 15, "facecolor": "grey", "edgecolor": "black", }, "edge": { "color": "#222", "linewidth": 1, }, }, ) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.058 seconds) .. _sphx_glr_download_gallery_basic_plot_dag.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_dag.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_dag.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_dag.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_