Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
trac #18972: inplace seidel_switching
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanncohen committed Aug 20, 2015
1 parent d9b098a commit e7022f3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/sage/combinat/designs/twographs.py
Expand Up @@ -207,6 +207,6 @@ def twograph_descendant(G, v):
sage: twograph_descendant(T8, v).is_strongly_regular(parameters=True)
(27, 16, 10, 8)
"""
G = G.seidel_switching(G.neighbors(v))
G = G.seidel_switching(G.neighbors(v),inplace=False)
G.delete_vertex(v)
return G
32 changes: 22 additions & 10 deletions src/sage/graphs/graph.py
Expand Up @@ -5062,8 +5062,8 @@ def seidel_adjacency_matrix(self, vertices=None):
self.complement().adjacency_matrix(sparse=False, \
vertices=vertices)

def seidel_switching(self, s):
"""
def seidel_switching(self, s, inplace=True):
r"""
Returns the Seidel switching of ``self`` w.r.t. subset of vertices ``s``.
Returns the graph obtained by Seidel switching of ``self``
Expand All @@ -5076,6 +5076,9 @@ def seidel_switching(self, s):
- ``s`` -- a list of vertices of ``self``
- ``inplace`` (boolean) -- whether to do the modification inplace, or to
return a copy of the graph after switching.
OUTPUT:
- :class:`~Graph` which is the switching of ``self`` w.r.t. ``s``
Expand All @@ -5084,17 +5087,26 @@ def seidel_switching(self, s):
sage: G = graphs.CycleGraph(5)
sage: G = G.disjoint_union(graphs.CompleteGraph(1))
sage: H = G.seidel_switching([(0,1),(1,0),(0,0)])
sage: H.seidel_adjacency_matrix().minpoly()
sage: G.seidel_switching([(0,1),(1,0),(0,0)])
sage: G.seidel_adjacency_matrix().minpoly()
x^2 - 5
sage: H.is_connected()
sage: G.is_connected()
True
TESTS::
sage: H = G.seidel_switching([1,4,5],inplace=False)
sage: G.seidel_switching([1,4,5])
sage: G == H
True
"""
from itertools import product
H = copy(self)
H.add_edges(product(s, set(self).difference(s)))
H.delete_edges(self.edge_boundary(s))
return H
G = self if inplace else self.copy()
boundary = self.edge_boundary(s)
G.add_edges(product(s, set(self).difference(s)))
G.delete_edges(boundary)
if not inplace:
return G

def twograph(self):
r"""
Expand All @@ -5111,7 +5123,7 @@ def twograph(self):
Incidence structure with 10 points and 60 blocks
sage: p=graphs.chang_graphs()
sage: T8 = graphs.CompleteGraph(8).line_graph()
sage: C = T8.seidel_switching([(0,1,None),(2,3,None),(4,5,None),(6,7,None)])
sage: C = T8.seidel_switching([(0,1,None),(2,3,None),(4,5,None),(6,7,None)],inplace=False)
sage: T8.twograph()==C.twograph()
True
sage: T8.is_isomorphic(C)
Expand Down
5 changes: 1 addition & 4 deletions src/sage/graphs/strongly_regular_db.pyx
Expand Up @@ -626,10 +626,7 @@ def SRG_196_91_42_42():
W = map(frozenset,[[x+z for x in H] for z in G])
G = IntersectionGraph(U+V+W)
# G = G.seidel_switching(U)
boundary = G.edge_boundary(U)
G.add_edges((x,y) for x in V+W for y in U)
G.delete_edges(boundary)
G.seidel_switching(U)
G.add_edges((-1,x) for x in U)
G.relabel()
Expand Down

0 comments on commit e7022f3

Please sign in to comment.