-
Notifications
You must be signed in to change notification settings - Fork 0
/
hyper_graph_to_graph.py
35 lines (33 loc) · 1.03 KB
/
hyper_graph_to_graph.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
import itertools
import numpy as np
edge_vs = {}
rows = []
cols = []
data = []
with open("unstructured_hgraph_small_P02.txt") as infile:
for line in infile:
if len(line.split(" ")) == 3:
size = int(line.split(" ")[0])
for i in range(0, size):
edge_vs[i] = []
elif line == "\n" or '#' in line:
continue
else:
line_splitted = line.split(" ")
edge_vs[int(line_splitted[0])].append(int(line_splitted[1][0:-1]))
for e1 in edge_vs:
print(len(rows),e1)
nodes = edge_vs[e1]
print(len(nodes))
if len(nodes) >= 3:
combs = itertools.combinations(nodes, 3)
for comb in combs:
for e2 in edge_vs:
if e1 > e2:
nodes_e2 = edge_vs[e2]
if set(list(comb)).issubset(set(nodes_e2)):
rows.append(e1)
cols.append(e2)
print(rows)
print(cols)
# print(edge_vs)