# HG changeset patch
# User Nathann Cohen <nathann.cohen@gmail.com>
# Date 1373063764 -7200
# Sat Jul 06 00:36:04 2013 +0200
# Node ID 13d3870bed98a2ee47fadf53f2fd0286cec5e1eb
# Parent 5d8c13e7b81a1e152855073f97a4d48ee97255d1
Implements Hypergraph.automorphism_group
diff --git a/sage/graphs/hypergraph.py b/sage/graphs/hypergraph.py
a
|
b
|
|
2 | 2 | Hypergraphs |
3 | 3 | |
4 | 4 | This module consists in a very basic implementation of :class:`Hypergraph`, |
5 | | whose only current purpose is to provide method to visualize them. This is |
6 | | done at the moment through `\LaTeX` and TikZ, and can be obtained from Sage |
7 | | through the ``view`` command:: |
| 5 | whose only current purpose is to observe them : it can be used to compute |
| 6 | automorphism groups and to draw them. The latter is done at the moment through |
| 7 | `\LaTeX` and TikZ, and can be obtained from Sage through the ``view`` command:: |
8 | 8 | |
9 | 9 | sage: H = Hypergraph([{1,2,3},{2,3,4},{3,4,5},{4,5,6}]); H |
10 | 10 | Hypergraph on 6 vertices containing 4 sets |
… |
… |
|
252 | 252 | tex += "\\end{tikzpicture}" |
253 | 253 | return tex |
254 | 254 | |
| 255 | |
| 256 | def automorphism_group(self): |
| 257 | r""" |
| 258 | Returns the automorphism group. |
| 259 | |
| 260 | For more information on the automorphism group of a hypergraph, see the |
| 261 | :wikipedia:`Hypergraph`. |
| 262 | |
| 263 | EXAMPLE:: |
| 264 | |
| 265 | sage: H = designs.steiner_triple_system(7).blocks() |
| 266 | sage: H = Hypergraph(H) |
| 267 | sage: g = H.automorphism_group(); g |
| 268 | Permutation Group with generators [(2,4)(5,6), (2,5)(4,6), (1,2)(3,4), (1,3)(5,6), (0,1)(2,5)] |
| 269 | sage: g.is_isomorphic(groups.permutation.PGL(3,2)) |
| 270 | True |
| 271 | """ |
| 272 | from sage.graphs.graph import Graph |
| 273 | from sage.groups.perm_gps.permgroup import PermutationGroup |
| 274 | |
| 275 | G = Graph() |
| 276 | domain = list(self.domain()) |
| 277 | G.add_vertices(domain) |
| 278 | for s in self._sets: |
| 279 | for i in s: |
| 280 | G.add_edge(s,i) |
| 281 | |
| 282 | ag = G.automorphism_group(partition=[domain,list(self._sets)]) |
| 283 | |
| 284 | gens = [ [tuple(c) for c in g.cycle_tuples() if c[0] in domain] |
| 285 | for g in ag.gens()] |
| 286 | |
| 287 | return PermutationGroup(gens = gens, domain = domain) |