.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/02_topology/plot_04_edge_lifetime.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 or to run this example in your browser via Binder. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_02_topology_plot_04_edge_lifetime.py: Edge lifetime decides which links survive ========================================= All topology learners delete links that have not been refreshed for a given number of steps. A long lifetime keeps transient links created while the nodes were still moving and links that jump between neighboring windings of the swiss roll; a short lifetime keeps only the links supported by the data. The suggestion of the WINN paper, a maximal age of N/10, is far too large for a curved manifold. .. GENERATED FROM PYTHON SOURCE LINES 12-33 .. image-sg:: /auto_examples/02_topology/images/sphx_glr_plot_04_edge_lifetime_001.png :alt: WINN, maximal edge age 200: 461 edges, WINN, maximal edge age 3: 2 edges :srcset: /auto_examples/02_topology/images/sphx_glr_plot_04_edge_lifetime_001.png :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt from graphclust import WeightedIncrementalNetwork from graphclust.datasets import make_swiss_roll, minmax_scale from graphclust.plotting import plot_graph X = minmax_scale(make_swiss_roll(2000, random_state=0)[0]) fig = plt.figure(figsize=(9, 4)) for i, age in enumerate([len(X) / 10, 3]): # [snippet:age] winn = WeightedIncrementalNetwork(n_nodes=200, max_age=age, random_state=0).fit(X) # [/snippet:age] ax = fig.add_subplot(1, 2, i + 1, projection="3d") plot_graph(winn.nodes_, winn.adjacency_, ax=ax, node_size=5, lw=0.5) ax.set_title(f"WINN, maximal edge age {age:g}: {winn.n_edges_} edges", fontsize=10) ax.view_init(10, -70) ax.set_xticks([]) ax.set_yticks([]) ax.set_zticks([]) plt.tight_layout() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 6.590 seconds) .. _sphx_glr_download_auto_examples_02_topology_plot_04_edge_lifetime.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/ComplexSystemsIntelligence/graphclust/main?urlpath=lab/tree/notebooks/auto_examples/02_topology/plot_04_edge_lifetime.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_04_edge_lifetime.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_04_edge_lifetime.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_04_edge_lifetime.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_