Adapters example

Last run 2021-10-08 with kmapper version 2.0.1

Demonstration using the networkx adapter. This example requires installing the networkx library before continuing:

pip install networkx
import kmapper
from sklearn import datasets
import networkx as nx

Construct data and a simple Mapper

data = datasets.make_circles(n_samples=1000)[0]
km = kmapper.KeplerMapper()
lens = km.project(data)
graph =, lens=lens)

Convert Mapper to a networkx graph

We can easily convert the graph to a networkx graph representation. This enables us to use many of the commonly provided algorithms and visualization methods.

nx_graph = kmapper.adapter.to_nx(graph)