Commit 5beba525 authored by Radek Hušek's avatar Radek Hušek Committed by Radek Hušek
Browse files

Add optimization based on matching subgraphs

If group has size 4 and graph contains one of following
subgraphs, it cannot be group-connected:
- vertex with all neighbours of degree 2
- vertex such that 2 of 3 his neighbours has degree 2 and so
  do their neighbours
- edge such that all 4 of her neighbours have degree 2
parent aa78b11d
......@@ -38,9 +38,21 @@ def pathToEdges(G, path):
return ret
def theOtherNeighbour(G, v, w):
"""
Given vertex v of degree 2 returns neighbour
of v not equal to w.
"""
N = G.neighbors(v)
if N[0] == w:
return N[1]
else:
return N[0]
def testGroupConnectivity(G, group = "Z4", getClasses = False,
useTwoCuts = True, useDoubleSubdivisions = True,
debug = False):
useSubgraphs = True, debug = False):
cdef AbstractTester* tester = NULL
if group == "Z4":
tester = new Tester[Z4[int]]()
......@@ -51,6 +63,20 @@ def testGroupConnectivity(G, group = "Z4", getClasses = False,
assert(tester != NULL)
if useSubgraphs and group in ["Z4", "Z2_2"] and not getClasses:
for v in G.vertex_iterator():
degs = sorted(G.degree(G.neighbors(v)))
if degs[-1] <= 2:
return False
if len(degs) == 3 and degs[0] <= 2 and degs[1] <= 2:
N = [ theOtherNeighbour(G, w, v) for w in G.neighbors(v) if G.degree(w) <= 2 ]
if G.degree(N) == [ 2, 2 ]:
return False
for (u, v, _) in G.edge_iterator():
if sorted(G.degree(G.neighbors(u))) == [ 2, 2, 3 ] and \
sorted(G.degree(G.neighbors(v))) == [ 2, 2, 3 ]:
return False
if useTwoCuts:
G.relabel()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment