Skip to content
Snippets Groups Projects
Commit f8d714f2 authored by Radek Hušek's avatar Radek Hušek
Browse files

Extend UnderlyingGraph parameter to free edges

parent 7dc759bc
No related branches found
No related tags found
No related merge requests found
...@@ -109,6 +109,10 @@ def _init_(): ...@@ -109,6 +109,10 @@ def _init_():
BV((0, 0, 0), Graph([[0], []], multiedges=True, loops=True, immutable=True)) BV((0, 0, 0), Graph([[0], []], multiedges=True, loops=True, immutable=True))
] ]
FREE_EDGE = [
BV((0, 0), Graph([[0], []], multiedges=True, loops=True, immutable=True))
]
def join_boundaries(self, x, _): def join_boundaries(self, x, _):
offsets = [0] offsets = [0]
for b in x: for b in x:
...@@ -137,17 +141,25 @@ def _init_(): ...@@ -137,17 +141,25 @@ def _init_():
def merge_values(self, a, b): assert False def merge_values(self, a, b): assert False
def finalize(self, b): def finalize(self, b):
from sage.all import Graph
assert len(b) == 1 assert len(b) == 1
assert b[0].boundary == tuple() assert b[0].boundary == tuple()
return b[0].value G = Graph(b[0].value, immutable=False)
for v in G.vertices():
if G.degree(v) != 2: continue
u, w = G.neighbors(v)
G.add_edge(u, w)
G.delete_vertex(v)
return Graph(G, immutable=True)
@Singleton @Singleton
class VertexCount(GraphParameterBase): class VertexCount(GraphParameterBase):
"""Count vertices of gadget. """Count vertices of gadget.
Same as `gadget.eval(UnderlyingGraph).num_verts()` but Same as `gadget.eval(UnderlyingGraph).num_verts()`.
also works for gadgets containing FREE_EDGE.
""" """
CUBIC_VERTEX = [ BV(None, 1) ] CUBIC_VERTEX = [ BV(None, 1) ]
FREE_EDGE = [ BV(None, 0) ] FREE_EDGE = [ BV(None, 0) ]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment