Esempio n. 1
0
def TaylorTwographSRG(q):
    r"""
    constructing a strongly regular graph from the Taylor's two-graph for `U_3(q)`, `q` odd

    This is a strongly regular graph with parameters
    `(v,k,\lambda,\mu)=(q^3+1, q(q^2+1)/2, (q^2+3)(q-1)/4, (q^2+1)(q+1)/4)`
    in the Seidel switching class of
    :func:`Taylor two-graph <sage.combinat.designs.twographs.taylor_twograph>`.
    Details are in §7E of [BvL84]_.

    INPUT:

    - ``q`` -- a power of an odd prime number

    .. SEEALSO::

        * :meth:`~sage.graphs.graph_generators.GraphGenerators.TaylorTwographDescendantSRG`

    EXAMPLES::

        sage: t=graphs.TaylorTwographSRG(3); t
        Taylor two-graph SRG: Graph on 28 vertices
        sage: t.is_strongly_regular(parameters=True)
        (28, 15, 6, 10)

    """
    G, l, v0 = TaylorTwographDescendantSRG(q, clique_partition=True)
    G.add_vertex(v0)
    G.seidel_switching(sum(l[:(q**2+1)/2],[]))
    G.name("Taylor two-graph SRG")
    return G
Esempio n. 2
0
def sum(xs, y_from_x=lambda x: x):
    '''
    >>> range(10) | sum()
    45
    >>> range(10) | sum(lambda x: -x)
    -45
    '''
    return __builtins__.sum(y_from_x(x) for x in xs)
Esempio n. 3
0
def count(xs, predicate=lambda x: True):
    '''
    >>> [1, 2, 3] | count()
    3
    >>> range(10) | where(lambda x: x % 2 == 0) | count()
    5
    >>> [] | count()
    0
    '''
    return __builtins__.sum(1 for x in xs | where(predicate))
Esempio n. 4
0
def is_twograph(T):
    r"""
    Checks that the incidence system `T` is a two-graph

    INPUT:

    - ``T`` -- an :class:`incidence structure <sage.combinat.designs.IncidenceStructure>`

    EXAMPLES:

    a two-graph from a graph::

        sage: from sage.combinat.designs.twographs import (is_twograph, TwoGraph)
        sage: p=graphs.PetersenGraph().twograph()
        sage: is_twograph(p)
        True

    a non-regular 2-uniform hypergraph which is a two-graph::

        sage: is_twograph(TwoGraph([[1,2,3],[1,2,4]]))
        True

    TESTS:

    wrong size of blocks::

        sage: is_twograph(designs.projective_plane(3))
        False

    a triple system which is not a two-graph::

        sage: is_twograph(designs.projective_plane(2))
        False
    """
    if not T.is_uniform(3):
        return False

    # A structure for a fast triple existence check
    v_to_blocks = {v:set() for v in range(T.num_points())}
    for B in T._blocks:
        B = frozenset(B)
        for x in B:
            v_to_blocks[x].add(B)

    def has_triple(x_y_z):
        x, y, z = x_y_z
        return bool(v_to_blocks[x] & v_to_blocks[y] & v_to_blocks[z])

    # Check that every quadruple contains an even number of triples
    from six.moves.builtins import sum
    for quad in combinations(range(T.num_points()),4):
        if sum(map(has_triple,combinations(quad,3))) % 2 == 1:
            return False

    return True
Esempio n. 5
0
def is_twograph(T):
    r"""
    Checks that the incidence system `T` is a two-graph

    INPUT:

    - ``T`` -- an :class:`incidence structure <sage.combinat.designs.IncidenceStructure>`

    EXAMPLES:

    a two-graph from a graph::

        sage: from sage.combinat.designs.twographs import (is_twograph, TwoGraph)
        sage: p=graphs.PetersenGraph().twograph()
        sage: is_twograph(p)
        True

    a non-regular 2-uniform hypergraph which is a two-graph::

        sage: is_twograph(TwoGraph([[1,2,3],[1,2,4]]))
        True

    TESTS:

    wrong size of blocks::

        sage: is_twograph(designs.projective_plane(3))
        False

    a triple system which is not a two-graph::

        sage: is_twograph(designs.projective_plane(2))
        False
    """
    if not T.is_uniform(3):
        return False

    # A structure for a fast triple existence check
    v_to_blocks = {v:set() for v in range(T.num_points())}
    for B in T._blocks:
        B = frozenset(B)
        for x in B:
            v_to_blocks[x].add(B)

    def has_triple(x_y_z):
        x, y, z = x_y_z
        return bool(v_to_blocks[x] & v_to_blocks[y] & v_to_blocks[z])

    # Check that every quadruple contains an even number of triples
    from six.moves.builtins import sum
    for quad in combinations(range(T.num_points()),4):
        if sum(map(has_triple,combinations(quad,3))) % 2 == 1:
            return False

    return True
Esempio n. 6
0
 def S(x, y):
     return sum(x[j] * y[2 - j] ** q for j in range(3))
Esempio n. 7
0
 def P(x, y):
     return sum(x[j] * y[m - 1 - j] ** q for j in range(m)) == 0