PGM results and bipartite code

This commit is contained in:
2025-10-23 10:21:26 +08:00
parent dd06bbec21
commit 301670b350
3 changed files with 179 additions and 5 deletions

View File

@@ -29,8 +29,9 @@ def cogirthip(bases, integral=true):
cnt=0 # actual number of instances tested
maxgap=0
f = lambda g: g.is_connected()
for N in range(8,20):
for N in range(4,10):
for g in filter(f, graphs(N)):
A=g.incidence_matrix()
n,m = A.dimensions()
@@ -47,9 +48,13 @@ for N in range(8,20):
strength=cogirthip(bases,integral=false)
cogirth =cogirthip(bases,integral=true)
gap = cogirth/strength
if gap > 3.01:
print(f"bad example! gap={gap}")
# maxgap=max(gap,maxgap)
if gap > maxgap:
maxgap = gap
print(f"find a large gap: {gap}")
with open("projection.out", "a") as file:
file.write(str(gap)+"\n"+str(A_t)+"\n")
file.write("##################################\n"
+str(gap)+"\n"+str(A_t)
+"\n##################################\n")
if cnt%100==0:
print(f"#{cnt},n={n},m={m}")
print(f"#{cnt}, n={n}, max gap = {maxgap}")