-
Notifications
You must be signed in to change notification settings - Fork 1
/
empirical_simpliciality.py
50 lines (39 loc) · 1.16 KB
/
empirical_simpliciality.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import json
import os
import xgi
from sod import *
if not os.path.exists("Data"):
os.mkdir("Data")
if not os.path.exists("Figures"):
os.mkdir("Figures")
datasets = [
"contact-primary-school",
"contact-high-school",
"hospital-lyon",
"email-enron",
"email-eu",
"ndc-substances",
"diseasome",
"disgenenet",
"congress-bills",
"tags-ask-ubuntu",
]
min_size = 2
try:
with open(f"Data/empirical_simpliciality.json", "r") as file:
data = json.loads(file.read())
except:
data = dict()
# This argument is very important to the computational feasibility of this algorithm
max_order = 10
for d in datasets:
data[d] = dict()
H = xgi.load_xgi_data(d, max_order=max_order)
H.cleanup(singletons=True)
data[d]["es"] = edit_simpliciality(H, min_size=min_size)
data[d]["fes"] = face_edit_simpliciality(H, min_size=min_size)
data[d]["sf"] = simplicial_fraction(H, min_size=min_size)
print("Just finished ", d, flush=True)
with open(f"Data/empirical_simpliciality.json", "w") as file:
datastring = json.dumps(data, indent=2)
file.write(datastring)