4. Basic tutorial: MapperGraph
class
[1]:
import networkx as nx
import matplotlib.pyplot as plt
import numpy as np
# The main class for the Reeb Graph
from cereeberus import MapperGraph, ReebGraph
# Some built in example graphs
import cereeberus.data.ex_reebgraphs as ex_rg
import cereeberus.data.ex_mappergraphs as ex_mg
Mapper graphs are similar to Reeb graphs, except that: - The value of \(f\) are integers in some range, [n_low, ... , n_high]
. - We store a delta
so that we can equivalently think of the function values as being [delta * n_low, ... , delta * n_high]
. - All edges have adjacent integers for function values. Equivalently, the inverse image of an integer is only vertices, no internal points of edges. This can be done by subdividing any edge as needed.
[14]:
MG = MapperGraph( seed = 0, delta = 1)
MG.add_node('A', f_vertex = 3)
MG.add_node('B', f_vertex = 1)
MG.add_node('C', f_vertex = 0)
MG.add_node('D', f_vertex = -2)
MG.add_node('E', f_vertex = 3)
MG.add_node('F', f_vertex = 1)
MG.add_edge('A','B')
MG.add_edge('B','C')
MG.add_edge('A','D')
MG.add_edge('D','E')
MG.add_edge('D','B')
MG.add_edge('D','B')
MG.add_edge('C','F')
# These positions are the locations for the drawing
MG.set_pos_from_f(seed = 8)
MG.draw(cpx = 1)
We can convert a ReebGraph
class instance into a MapperGraph
class instance. Note that this is NOT the same as computing the mapper graph of a Reeb graph treated as the input object.
[21]:
R = ex_rg.dancing_man(seed = 0)
R.draw()
print(R.f)
{0: 7, 1: 6, 2: 5, 3: 5, 4: 6, 5: 4, 6: 4, 7: 1}
[22]:
MG = R.to_mapper()
MG.draw()
However, if the Reeb graph has any vertices with a non-integer function value, no mapper graph instance can be created.