-
Notifications
You must be signed in to change notification settings - Fork 0
/
poset_test.py
133 lines (123 loc) · 1.74 KB
/
poset_test.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import poset_HnN, poset_partial
HNpc = poset_HnN.partial_cover
MYpc = poset_partial.partial_cover
tc = poset_HnN.trans_closure
rmtc = poset_partial.rm_trans_closure
ls = poset_partial.get_linearizations
def test(lins, target):
rets = list(map(lambda x: rmtc(target,x), MYpc(lins, target)))
for ret in rets:
print(ret)
#print(ls(target,tc(ret)))
print()
tmp = []
x = HNpc(lins, target)
while len(tmp) < len(rets):
# infinite loop
if x == False:
print('e',end=' ') # not possible now
# sub optimal
elif x[0] not in rets:
print('sub:', end=' ')
else:
tmp.append(x[0])
print(x[2])
x = HNpc(lins, target)
print()
for t in tmp:
print(t)
#print(ls(target,tc(ret)))
'''
# counter
lins1 = [
'afbced',
'afbecd',
'abfecd',
'bfaced',
'bafced',
'abfced',
'bacfed',
'abcfed',
'bacefd',
'abcefd'
]
print('test1')
test(lins1,'abfced')
print()
# cut
lins2 = [
'adbc',
'adcb',
'acdb',
'acbd',
'abcd'
]
print('test2')
test(lins2,'acdb')
print()
#long
lins3 = [
'abcdef',
'badcef',
'badcfe',
'abdcfe'
]
print('test3')
test(lins3,'badcfe')
print()
# many covers
lins4 = [
'abcdef',
'acbdef',
'acbdfe',
'acbfde',
'adcbef',
'acdbef',
'acdbfe',
'acdfbe'
]
print('test4')
test(lins4,'acbdef')
print()
# new way
lins5 = [
'abcdef',
'acbdfe',
'acbfde',
'acdbfe',
'acdfbe',
'adcbef'
]
print('test5')
test(lins5,'acbdfe')
print()
# paper
lins6 = [
'abcde',
'bacde',
'bcade',
'cbade',
'cabde',
'acbde',
'abced',
'baced',
'acbed',
'bcaed',
'cbaed'
]
print('test6')
test(lins6,'abced')
print()
# problem
lins7 = [
'adcb',
'acdb',
'acbd',
'abcd'
]
print('test7')
test(lins7,'acdb')
print()
'''
ls = ['abfce','bafce','abcfe','abfec']
test(ls,'abfce')