Esempio n. 1
0
                if multiedges is False:
                    v = next((v for v in D[u] if D[u].count(v) > 1))
                    raise ValueError(
                        "non-multigraph got several edges (%s, %s)" % (u, v))
                multiedges = True
                break
        if multiedges is None:
            multiedges = False
    G.allow_loops(loops, check=False)
    G.allow_multiple_edges(multiedges, check=False)
    G.add_vertices(verts)

    is_directed = G.is_directed()
    if not is_directed and multiedges:
        v_to_id = {v: i for i, v in enumerate(verts)}
        for u in D:
            for v in D[u]:
                if (v_to_id[u] <= v_to_id[v] or v not in D or u not in D[v]
                        or u == v):
                    G._backend.add_edge(u, v, None, False)
    else:
        for u in D:
            for v in D[u]:
                G._backend.add_edge(u, v, None, is_directed)


from sage.misc.rest_index_of_methods import gen_rest_table_index
import sys
__doc__ = __doc__.format(
    INDEX_OF_FUNCTIONS=gen_rest_table_index(sys.modules[__name__]))
Esempio n. 2
0
         'QuadraticResidueCode', 'QuadraticResidueCodeEvenPair',
         'QuadraticResidueCodeOddPair', 'random_linear_code',
         'ToricCode', 'WalshCode'])

lazy_import('sage.coding.bch', 'BCHCode')
lazy_import('sage.coding.cyclic_code', 'CyclicCode')
lazy_import('sage.coding.extended_code', 'ExtendedCode')
lazy_import('sage.coding.golay_code', 'GolayCode')
lazy_import('sage.coding.grs', ['GeneralizedReedSolomonCode', 'ReedSolomonCode'])
lazy_import('sage.coding.guava', ['QuasiQuadraticResidueCode',
                                    'RandomLinearCodeGuava'])
lazy_import('sage.coding.hamming_code', 'HammingCode')
lazy_import('sage.coding.parity_check_code', 'ParityCheckCode')
lazy_import('sage.coding.punctured_code', 'PuncturedCode')
lazy_import('sage.coding.reed_muller_code', ['BinaryReedMullerCode',
                                              'ReedMullerCode'])
lazy_import('sage.coding.subfield_subcode', 'SubfieldSubcode')

from . import decoders_catalog as decoders
from . import encoders_catalog as encoders
from . import bounds_catalog as bounds

lazy_import('sage.coding','databases')

from sage.misc.rest_index_of_methods import gen_rest_table_index
import sys
__doc__ = __doc__.format(INDEX_OF_FUNCTIONS=gen_rest_table_index(sys.modules[__name__], only_local_functions=False))

# We don't want this to appear in tab completion
del absolute_import, lazy_import, sys, gen_rest_table_index
Esempio n. 3
0
    if not multiedges:
        for u in D:
            if len(set(D[u])) != len(D[u]):
                if multiedges is False:
                    v = next((v for v in D[u] if D[u].count(v) > 1))
                    raise ValueError("non-multigraph got several edges (%s, %s)"%(u, v))
                multiedges = True
                break
        if multiedges is None:
            multiedges = False
    G.allow_loops(loops, check=False)
    G.allow_multiple_edges(multiedges, check=False)
    G.add_vertices(verts)

    is_directed = G.is_directed()
    if not is_directed and multiedges:
        v_to_id = {v: i for i, v in enumerate(verts)}
        for u in D:
            for v in D[u]:
                if (v_to_id[u] <= v_to_id[v] or
                    v not in D or u not in D[v] or u == v):
                    G._backend.add_edge(u, v, None, False)
    else:
        for u in D:
            for v in D[u]:
                G._backend.add_edge(u, v, None, is_directed)

from sage.misc.rest_index_of_methods import gen_rest_table_index
import sys
__doc__ = __doc__.format(INDEX_OF_FUNCTIONS=gen_rest_table_index(sys.modules[__name__]))
Esempio n. 4
0
])

lazy_import('sage.coding.bch', 'BCHCode')
lazy_import('sage.coding.cyclic_code', 'CyclicCode')
lazy_import('sage.coding.extended_code', 'ExtendedCode')
lazy_import('sage.coding.golay_code', 'GolayCode')
lazy_import('sage.coding.grs',
            ['GeneralizedReedSolomonCode', 'ReedSolomonCode'])
lazy_import('sage.coding.guava',
            ['QuasiQuadraticResidueCode', 'RandomLinearCodeGuava'])
lazy_import('sage.coding.hamming_code', 'HammingCode')
lazy_import('sage.coding.parity_check_code', 'ParityCheckCode')
lazy_import('sage.coding.punctured_code', 'PuncturedCode')
lazy_import('sage.coding.reed_muller_code',
            ['BinaryReedMullerCode', 'ReedMullerCode'])
lazy_import('sage.coding.subfield_subcode', 'SubfieldSubcode')

from . import decoders_catalog as decoders
from . import encoders_catalog as encoders
from . import bounds_catalog as bounds

lazy_import('sage.coding', 'databases')

from sage.misc.rest_index_of_methods import gen_rest_table_index
import sys
__doc__ = __doc__.format(INDEX_OF_FUNCTIONS=gen_rest_table_index(
    sys.modules[__name__], only_local_functions=False))

# We don't want this to appear in tab completion
del absolute_import, lazy_import, sys, gen_rest_table_index
Esempio n. 5
0
            q = pow(*factorization[1])
            if p > q:
                p,q = q,p
            G,D = twin_prime_powers_difference_set(p,check=False)

    if D is None and are_hyperplanes_in_projective_geometry_parameters(v,k,l):
        _, (q,d) = are_hyperplanes_in_projective_geometry_parameters(v,k,l,True)
        if existence:
            return True
        elif explain_construction:
            return "Singer difference set"
        else:
            G,D = singer_difference_set(q,d)

    if D is None:
        if existence:
            return Unknown
        raise NotImplementedError("No constructions for these parameters")

    if check and not is_difference_family(G,D,v=v,k=k,l=l,verbose=False):
        raise RuntimeError("There is a problem. Sage built the following "
                "difference family on G='{}' with parameters ({},{},{}):\n "
                "{}\nwhich seems to not be a difference family... "
                "Please contact [email protected]".format(G,v,k,l,D))

    return G, D

from sage.misc.rest_index_of_methods import gen_rest_table_index
import sys
__doc__ = __doc__.format(INDEX_OF_FUNCTIONS=gen_rest_table_index(sys.modules[__name__]))
Esempio n. 6
0
                    6772299, 35771935, 36738719, 12895471, 36745439, 12805355,
                    21187947, 6494955, 6887803, 71517563, 38931835, 38933755,
                    100863355, 37950715, 12782971, 38868347, 6508795, 31004235,
                    55776843, 14197997, 26330711, 6888047, 21564783, 21370331,
                    12985819, 21582943, 12888303, 10823919, 25562587, 25496815,
                    30106699, 155852363, 147594827, 147150411, 14191993,
                    12963177, 21287151, 37971055, 26318547, 25796179, 38937839,
                    38937951, 25479407, 84100335, 12902639, 25288943, 19076823,
                    38868575, 10692255, 21566703, 10660511, 10689119, 25800263,
                    21160175, 6953567, 6639855, 6893807, 7084271, 38872431,
                    25407171, 51449199, 51451119, 25481439, 26297567, 76096735,
                    19091679, 25340127, 50501855, 6462239, 26741983, 6705375,
                    25562335, 13145339, 12684911, 7902814, 13145695, 12750431,
                    12687083, 21140955, 21138923, 12750075, 21091919, 37850735,
                    36000863, 11617887, 42067039, 10587823, 6393647, 21073135,
                    13944043, 21141199, 36771423, 12756575, 100767327,
                    21139279, 21153007, 21153119, 50435311, 35760479, 18991455,
                    50433375, 26264799, 75810015, 21087599, 12686971, 50500831,
                    19437791, 10653343, 12684655, 25726175, 10587935, 10816735,
                    6393207, 25267423, 6395259, 35753583, 18975983, 6481131,
                    19434847, 10798303, 10653279, 10783967, 6393199, 6393071,
                    6393055
                ]
            ]


__doc__ = __doc__.replace(
    "{INDEX_OF_METHODS}", (gen_rest_table_index(GraphGenerator))).replace(
        ":func:`~flexrilog.graph_generator.",
        ":func:`~flexrilog.graph_generator.GraphGenerator.")
Esempio n. 7
0
                    invariant_comps.append(orbit)
                else:
                    noninv_comps.append(orbit)

            self._partially_invariant_orbits[col] = invariant_comps
            self._noninvariant_orbits[col] = noninv_comps
            self._partially_invariant_components[col] = [
                list(comp) for orbit in invariant_comps for comp in orbit
            ]
            self._noninvariant_components[col] = [
                list(comp) for orbit in noninv_comps for comp in orbit
            ]

    def is_Cn_symmetric(self):
        if not self.is_equal(self.isomorphic_NAC_coloring(self.omega),
                             moduloConjugation=False):
            return False
        if len(self.blue_subgraph().subgraph(
                flatten(
                    self._partially_invariant_components['red'])).edges()) > 0:
            return False
        if len(self.red_subgraph().subgraph(
                flatten(self._partially_invariant_components['blue'])).edges()
               ) > 0:
            return False
        return True


__doc__ = __doc__.replace("{INDEX_OF_METHODS}",
                          (gen_rest_table_index(NACcoloring)))
Esempio n. 8
0
                            else:
                                res[u].append((v,w))
                                continue
                            h = self._field.hom(RR(r))
                            if h(ratio) <= 0:
                                res[u].append((v,w))
                        else:
                            raise NotImplementedError()
                except RuntimeError:
                    pass
        return {v: Set(res[v]).list() for v in res if res[v]}


    def merge_animations(self, motions, total_time=12, fps=25, **kwargs):
        r"""
        Return an animation by concatenating a list of motions.
        """
        realizations = []
        for M in motions:
            realizations += M.sample_motion(floor(total_time*fps/len(motions)))
        return super(ParametricGraphMotion, self).animation_SVG(realizations, **kwargs)




__doc__ = __doc__.replace(
    "{INDEX_OF_METHODS_GRAPH_MOTION}", gen_rest_table_index(GraphMotion))

__doc__ = __doc__.replace(
    "{INDEX_OF_METHODS_PARAMETRIC_GRAPH_MOTION}", gen_rest_table_index(ParametricGraphMotion))