Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New api for html file #70

Merged
merged 7 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading