Skip to content

Commit

Permalink
Merge pull request #70 from MathieuCarriere/New-API-for-HTML-file
Browse files Browse the repository at this point in the history
New api for html file
  • Loading branch information
VincentRouvreau authored Jan 26, 2024
2 parents c35dfff + d83fd60 commit 3ab7c33
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 2,204 deletions.
2 changes: 1 addition & 1 deletion .binder/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ tensorflow-addons
plotly
pot
networkx
gudhi!=3.7.0 # cf. https://github.com/GUDHI/TDA-tutorial/issues/65
gudhi>=3.9.0 # Tuto-GUDHI-cover-complex.ipynb requires sklearn interfaces
torch
tqdm
eagerpy
1,931 changes: 157 additions & 1,774 deletions Tuto-GUDHI-cover-complex.ipynb

Large diffs are not rendered by default.

44 changes: 5 additions & 39 deletions utils/KeplerMapperVisuFromTxtFile.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/usr/bin/env python

import km
import numpy as np
from collections import defaultdict
import argparse
from gudhi.cover_complex import _save_to_html

"""This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
Expand All @@ -30,48 +28,16 @@
args = parser.parse_args()

with open(args.file, 'r') as f:
network = {}
mapper = km.KeplerMapper(verbose=0)
data = np.zeros((3,3))
projected_data = mapper.fit_transform( data, projection="sum", scaler=None )

nodes = defaultdict(list)
links = defaultdict(list)
custom = defaultdict(list)

dat = f.readline()
lens = f.readline()
color = f.readline();
param = [float(i) for i in f.readline().split(" ")]

nums = [int(i) for i in f.readline().split(" ")]
num_nodes = nums[0]
num_edges = nums[1]

for i in range(0,num_nodes):
point = [float(j) for j in f.readline().split(" ")]
nodes[ str(int(point[0])) ] = [ int(point[0]), point[1], int(point[2]) ]
links[ str(int(point[0])) ] = []
custom[ int(point[0]) ] = point[1]

m = min([custom[i] for i in range(0,num_nodes)])
M = max([custom[i] for i in range(0,num_nodes)])

for i in range(0,num_edges):
edge = [int(j) for j in f.readline().split(" ")]
links[ str(edge[0]) ].append( str(edge[1]) )
links[ str(edge[1]) ].append( str(edge[0]) )

network["nodes"] = nodes
network["links"] = links
network["meta"] = lens

points = [[float(j) for j in f.readline().split(" ")] for i in range(0, nums[0])]
edges = [[int(j) for j in f.readline().split(" ")] for i in range(0, nums[1])]
html_output_filename = args.file.rsplit('.', 1)[0] + '.html'
mapper.visualize(network, color_function=color, path_html=html_output_filename, title=dat,
graph_link_distance=30, graph_gravity=0.1, graph_charge=-120, custom_tooltips=custom, width_html=0,
height_html=0, show_tooltips=True, show_title=True, show_meta=True, res=param[0],gain=param[1], minimum=m,maximum=M)
message = repr(html_output_filename) + " is generated. You can now use your favorite web browser to visualize it."
print(message)


f.close()

_save_to_html(dat, lens, color, param, points, edges, html_output_filename)
Loading

0 comments on commit 3ab7c33

Please sign in to comment.