Re: Persistence Diagram of a Graph

nchristianson@...
 

So it depends - how would you like to filter your graph? Do you want to add edges by increasing weight (e.g., say you have positive integer weights, and so you add all edges of weight 1 as the first step in the filtration, and then in the second step you also include all edges of weight 2, etc.)? If so, then if you have the weighted adjacency matrix of the graph, this weighted adjacency matrix can also act as a distance matrix for creating a Vietoris-Rips filtration, which will give you the persistent homology of this graph filtration. If W is your weighted adjacency matrix, then the code for this would be:

import dionysus as d
from scipy.spatial.distance import squareform

sq_dist = squareform(W)
f = d.fill_rips(sq_dist, k, np.max(W)) # creates the k-skeleton of the Vietoris-Rips filtration (edge weight filtration) of the graph
m = d.homology_persistence(f) # calculates persistent homology

and from here, there are some examples on the site for how to plot the barcode, extract cycles, etc. If you want to build a different filtration, this is also possible by manipulating the values of the distance matrix so certain edges are introduced before others.

Join dionysus@groups.io to automatically receive all group messages.