Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
22144 views
a

�Ul_h�@s�dZddlZddlmmZddlmZddl	m
Z
ddlmZddl
mZddlmZddlmZdd	lmZd
ZGdd�de
e�ZdS)
z�
Boolean graphs
==============

The ``boolean_graph`` module defines
the ``BooleanGraph``  class,
which represents a Graph whose order is a power of 2.

AUTHORS:

- Paul Leopardi (2017-11-11): initial version

�N)�log)�Graph)�matrix)�FiniteField)�Integer)�base2)�Saveable�sagecs.eZdZdZ�fdd�Zdefdd�Z�ZS)�BooleanGrapha�
    A Graph whose order is a power of 2.

    EXAMPLES:

    ::

        sage: from boolean_cayley_graphs.boolean_graph import BooleanGraph
        sage: g16 = BooleanGraph(16)
        sage: g16.order()
        16

    TESTS:

    ::

        sage: from boolean_cayley_graphs.boolean_graph import BooleanGraph
        sage: g16 = BooleanGraph(16)
        sage: print(g16)
        Graph on 16 vertices
    cs0tt|�j|i|��t|��d���s,t�dS)z�
        A Graph whose order is a power of 2.

        EXAMPLES:

        ::

            sage: from boolean_cayley_graphs.boolean_graph import BooleanGraph
            sage: g16 = BooleanGraph(8)
            sage: g16.order()
            8
        �N)�superr
�__init__r�order�
is_integer�
ValueError)�self�args�kwargs��	__class__��G/home/user/Boolean-Cayley-graphs/boolean_cayley_graphs/boolean_graph.pyr
<s
zBooleanGraph.__init__Fcs�|j|d�|j|d�krdS|j|dd�\}�|s>|r:dSdStt|��d���t��D]X}t|d��D]D}�d|�d|A�d|d|Akrj|r�dndSqjqX|s�dSttd���fdd	�t��D����}d|fS)
a3
        Check that the two BooleanGraphs ``self`` and ``other`` are isomorphic
        and that the isomorphism is given by a GF(2) linear mapping on the
        vector space of vertices.

        INPUT:

        - ``self`` -- the current object.
        - ``other`` -- another object of class BooleanFunctionImproved.
        - ``certificate`` -- bool (default False). If true, return a GF(2) matrix
           that defines the isomorphism.

        OUTPUT:

        If ``certificate`` is false, a bool value.
        If ``certificate`` is true, a tuple consisting of either (False, None)
        or (True, M), where M is a GF(2) matrix that defines the isomorphism.

        EXAMPLES:

        ::

            sage: from boolean_cayley_graphs.boolean_function_improved import BooleanFunctionImproved
            sage: from boolean_cayley_graphs.boolean_graph import BooleanGraph
            sage: bf1 = BooleanFunctionImproved([0,1,0,0])
            sage: cg1 = BooleanGraph(bf1.cayley_graph())
            sage: bf2 = BooleanFunctionImproved([0,0,1,0])
            sage: cg2 = BooleanGraph(bf2.cayley_graph())
            sage: cg1.is_linear_isomorphic(cg2)
            True
            sage: cg2.is_linear_isomorphic(cg1, certificate=True)
            (
                  [0 1]
            True, [1 0]
            )


        )�	algorithm)FNT)�certificateFr�cs"g|]}t�t�d|���qS)r)rr)�.0�a��dim�mappingrr�
<listcomp>�s�z5BooleanGraph.is_linear_isomorphic.<locals>.<listcomp>)	�canonical_label�
is_isomorphicrrr�ranger�GF�	transpose)r�otherrrr"r�bZmapping_matrixrrr�is_linear_isomorphicOs .,�z!BooleanGraph.is_linear_isomorphic)�__name__�
__module__�__qualname__�__doc__r
�default_algorithmr(�
__classcell__rrrrr
$s
�r
)r,�builtins�@py_builtins�_pytest.assertion.rewrite�	assertion�rewrite�
@pytest_ar�mathr�sage.graphs.graphr�sage.matrix.constructorr�0sage.rings.finite_rings.finite_field_constructorrr$�sage.rings.integerr�"boolean_cayley_graphs.integer_bitsr�boolean_cayley_graphs.saveablerr-r
rrrr�<module>s&