passagemath-graphs 10.6.1rc1__cp310-cp310-musllinux_1_2_aarch64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- passagemath_graphs-10.6.1rc1.dist-info/METADATA +292 -0
- passagemath_graphs-10.6.1rc1.dist-info/RECORD +260 -0
- passagemath_graphs-10.6.1rc1.dist-info/WHEEL +5 -0
- passagemath_graphs-10.6.1rc1.dist-info/top_level.txt +2 -0
- passagemath_graphs.libs/libgcc_s-69c45f16.so.1 +0 -0
- passagemath_graphs.libs/libgmp-8e78bd9b.so.10.5.0 +0 -0
- passagemath_graphs.libs/libstdc++-1f1a71be.so.6.0.33 +0 -0
- sage/all__sagemath_graphs.py +39 -0
- sage/combinat/abstract_tree.py +2723 -0
- sage/combinat/all__sagemath_graphs.py +34 -0
- sage/combinat/binary_tree.py +5306 -0
- sage/combinat/cluster_algebra_quiver/all.py +22 -0
- sage/combinat/cluster_algebra_quiver/cluster_seed.py +5208 -0
- sage/combinat/cluster_algebra_quiver/interact.py +124 -0
- sage/combinat/cluster_algebra_quiver/mutation_class.py +625 -0
- sage/combinat/cluster_algebra_quiver/mutation_type.py +1555 -0
- sage/combinat/cluster_algebra_quiver/quiver.py +2290 -0
- sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py +2468 -0
- sage/combinat/designs/MOLS_handbook_data.py +570 -0
- sage/combinat/designs/all.py +58 -0
- sage/combinat/designs/bibd.py +1655 -0
- sage/combinat/designs/block_design.py +1071 -0
- sage/combinat/designs/covering_array.py +269 -0
- sage/combinat/designs/covering_design.py +530 -0
- sage/combinat/designs/database.py +5615 -0
- sage/combinat/designs/design_catalog.py +122 -0
- sage/combinat/designs/designs_pyx.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/combinat/designs/designs_pyx.pxd +21 -0
- sage/combinat/designs/designs_pyx.pyx +993 -0
- sage/combinat/designs/difference_family.py +3951 -0
- sage/combinat/designs/difference_matrices.py +279 -0
- sage/combinat/designs/evenly_distributed_sets.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/combinat/designs/evenly_distributed_sets.pyx +661 -0
- sage/combinat/designs/ext_rep.py +1064 -0
- sage/combinat/designs/gen_quadrangles_with_spread.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/combinat/designs/gen_quadrangles_with_spread.pyx +339 -0
- sage/combinat/designs/group_divisible_designs.py +361 -0
- sage/combinat/designs/incidence_structures.py +2357 -0
- sage/combinat/designs/latin_squares.py +581 -0
- sage/combinat/designs/orthogonal_arrays.py +2244 -0
- sage/combinat/designs/orthogonal_arrays_build_recursive.py +1780 -0
- sage/combinat/designs/orthogonal_arrays_find_recursive.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/combinat/designs/orthogonal_arrays_find_recursive.pyx +967 -0
- sage/combinat/designs/resolvable_bibd.py +815 -0
- sage/combinat/designs/steiner_quadruple_systems.py +1306 -0
- sage/combinat/designs/subhypergraph_search.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/combinat/designs/subhypergraph_search.pyx +530 -0
- sage/combinat/designs/twographs.py +306 -0
- sage/combinat/finite_state_machine.py +14874 -0
- sage/combinat/finite_state_machine_generators.py +2006 -0
- sage/combinat/graph_path.py +448 -0
- sage/combinat/interval_posets.py +3908 -0
- sage/combinat/nu_tamari_lattice.py +269 -0
- sage/combinat/ordered_tree.py +1446 -0
- sage/combinat/posets/all.py +46 -0
- sage/combinat/posets/bubble_shuffle.py +247 -0
- sage/combinat/posets/cartesian_product.py +493 -0
- sage/combinat/posets/d_complete.py +182 -0
- sage/combinat/posets/elements.py +273 -0
- sage/combinat/posets/forest.py +30 -0
- sage/combinat/posets/hasse_cython.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/combinat/posets/hasse_cython.pyx +174 -0
- sage/combinat/posets/hasse_diagram.py +3672 -0
- sage/combinat/posets/hochschild_lattice.py +158 -0
- sage/combinat/posets/incidence_algebras.py +794 -0
- sage/combinat/posets/lattices.py +5117 -0
- sage/combinat/posets/linear_extension_iterator.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/combinat/posets/linear_extension_iterator.pyx +292 -0
- sage/combinat/posets/linear_extensions.py +1037 -0
- sage/combinat/posets/mobile.py +275 -0
- sage/combinat/posets/moebius_algebra.py +776 -0
- sage/combinat/posets/poset_examples.py +2178 -0
- sage/combinat/posets/posets.py +9360 -0
- sage/combinat/rooted_tree.py +1070 -0
- sage/combinat/shard_order.py +239 -0
- sage/combinat/tamari_lattices.py +384 -0
- sage/combinat/yang_baxter_graph.py +923 -0
- sage/databases/all__sagemath_graphs.py +1 -0
- sage/databases/knotinfo_db.py +1231 -0
- sage/ext_data/all__sagemath_graphs.py +1 -0
- sage/ext_data/graphs/graph_plot_js.html +330 -0
- sage/ext_data/kenzo/CP2.txt +45 -0
- sage/ext_data/kenzo/CP3.txt +349 -0
- sage/ext_data/kenzo/CP4.txt +4774 -0
- sage/ext_data/kenzo/README.txt +49 -0
- sage/ext_data/kenzo/S4.txt +20 -0
- sage/graphs/all.py +42 -0
- sage/graphs/asteroidal_triples.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/asteroidal_triples.pyx +320 -0
- sage/graphs/base/all.py +1 -0
- sage/graphs/base/boost_graph.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/base/boost_graph.pxd +106 -0
- sage/graphs/base/boost_graph.pyx +3045 -0
- sage/graphs/base/c_graph.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/base/c_graph.pxd +106 -0
- sage/graphs/base/c_graph.pyx +5096 -0
- sage/graphs/base/dense_graph.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/base/dense_graph.pxd +28 -0
- sage/graphs/base/dense_graph.pyx +801 -0
- sage/graphs/base/graph_backends.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/base/graph_backends.pxd +5 -0
- sage/graphs/base/graph_backends.pyx +797 -0
- sage/graphs/base/overview.py +85 -0
- sage/graphs/base/sparse_graph.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/base/sparse_graph.pxd +90 -0
- sage/graphs/base/sparse_graph.pyx +1653 -0
- sage/graphs/base/static_dense_graph.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/base/static_dense_graph.pxd +5 -0
- sage/graphs/base/static_dense_graph.pyx +1032 -0
- sage/graphs/base/static_sparse_backend.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/base/static_sparse_backend.pxd +27 -0
- sage/graphs/base/static_sparse_backend.pyx +1583 -0
- sage/graphs/base/static_sparse_graph.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/base/static_sparse_graph.pxd +37 -0
- sage/graphs/base/static_sparse_graph.pyx +1375 -0
- sage/graphs/bipartite_graph.py +2732 -0
- sage/graphs/centrality.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/centrality.pyx +1038 -0
- sage/graphs/cographs.py +519 -0
- sage/graphs/comparability.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/comparability.pyx +851 -0
- sage/graphs/connectivity.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/connectivity.pxd +157 -0
- sage/graphs/connectivity.pyx +4813 -0
- sage/graphs/convexity_properties.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/convexity_properties.pxd +16 -0
- sage/graphs/convexity_properties.pyx +870 -0
- sage/graphs/digraph.py +4754 -0
- sage/graphs/digraph_generators.py +1993 -0
- sage/graphs/distances_all_pairs.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/distances_all_pairs.pxd +12 -0
- sage/graphs/distances_all_pairs.pyx +2938 -0
- sage/graphs/domination.py +1363 -0
- sage/graphs/dot2tex_utils.py +100 -0
- sage/graphs/edge_connectivity.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/edge_connectivity.pyx +1215 -0
- sage/graphs/generators/all.py +1 -0
- sage/graphs/generators/basic.py +1769 -0
- sage/graphs/generators/chessboard.py +538 -0
- sage/graphs/generators/classical_geometries.py +1611 -0
- sage/graphs/generators/degree_sequence.py +235 -0
- sage/graphs/generators/distance_regular.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/generators/distance_regular.pyx +2846 -0
- sage/graphs/generators/families.py +4759 -0
- sage/graphs/generators/intersection.py +565 -0
- sage/graphs/generators/platonic_solids.py +262 -0
- sage/graphs/generators/random.py +2623 -0
- sage/graphs/generators/smallgraphs.py +5741 -0
- sage/graphs/generators/world_map.py +724 -0
- sage/graphs/generic_graph.py +26867 -0
- sage/graphs/generic_graph_pyx.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/generic_graph_pyx.pxd +34 -0
- sage/graphs/generic_graph_pyx.pyx +1673 -0
- sage/graphs/genus.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/genus.pyx +622 -0
- sage/graphs/graph.py +9645 -0
- sage/graphs/graph_coloring.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/graph_coloring.pyx +2284 -0
- sage/graphs/graph_database.py +1177 -0
- sage/graphs/graph_decompositions/all.py +1 -0
- sage/graphs/graph_decompositions/bandwidth.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/graph_decompositions/bandwidth.pyx +428 -0
- sage/graphs/graph_decompositions/clique_separators.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/graph_decompositions/clique_separators.pyx +616 -0
- sage/graphs/graph_decompositions/cutwidth.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/graph_decompositions/cutwidth.pyx +753 -0
- sage/graphs/graph_decompositions/fast_digraph.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/graph_decompositions/fast_digraph.pxd +13 -0
- sage/graphs/graph_decompositions/fast_digraph.pyx +212 -0
- sage/graphs/graph_decompositions/graph_products.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/graph_decompositions/graph_products.pyx +508 -0
- sage/graphs/graph_decompositions/modular_decomposition.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/graph_decompositions/modular_decomposition.pxd +27 -0
- sage/graphs/graph_decompositions/modular_decomposition.pyx +1536 -0
- sage/graphs/graph_decompositions/slice_decomposition.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/graph_decompositions/slice_decomposition.pxd +18 -0
- sage/graphs/graph_decompositions/slice_decomposition.pyx +1106 -0
- sage/graphs/graph_decompositions/tree_decomposition.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/graph_decompositions/tree_decomposition.pxd +17 -0
- sage/graphs/graph_decompositions/tree_decomposition.pyx +1996 -0
- sage/graphs/graph_decompositions/vertex_separation.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/graph_decompositions/vertex_separation.pxd +5 -0
- sage/graphs/graph_decompositions/vertex_separation.pyx +1963 -0
- sage/graphs/graph_editor.py +82 -0
- sage/graphs/graph_generators.py +3314 -0
- sage/graphs/graph_generators_pyx.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/graph_generators_pyx.pyx +95 -0
- sage/graphs/graph_input.py +812 -0
- sage/graphs/graph_latex.py +2064 -0
- sage/graphs/graph_list.py +410 -0
- sage/graphs/graph_plot.py +1756 -0
- sage/graphs/graph_plot_js.py +338 -0
- sage/graphs/hyperbolicity.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/hyperbolicity.pyx +1704 -0
- sage/graphs/hypergraph_generators.py +364 -0
- sage/graphs/independent_sets.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/independent_sets.pxd +13 -0
- sage/graphs/independent_sets.pyx +402 -0
- sage/graphs/isgci.py +1033 -0
- sage/graphs/isoperimetric_inequalities.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/isoperimetric_inequalities.pyx +489 -0
- sage/graphs/line_graph.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/line_graph.pyx +743 -0
- sage/graphs/lovasz_theta.py +77 -0
- sage/graphs/matching.py +1633 -0
- sage/graphs/matching_covered_graph.py +3590 -0
- sage/graphs/orientations.py +1489 -0
- sage/graphs/partial_cube.py +459 -0
- sage/graphs/path_enumeration.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/path_enumeration.pyx +2040 -0
- sage/graphs/pq_trees.py +1129 -0
- sage/graphs/print_graphs.py +201 -0
- sage/graphs/schnyder.py +865 -0
- sage/graphs/spanning_tree.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/spanning_tree.pyx +1457 -0
- sage/graphs/strongly_regular_db.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/strongly_regular_db.pyx +3340 -0
- sage/graphs/traversals.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/traversals.pxd +9 -0
- sage/graphs/traversals.pyx +1872 -0
- sage/graphs/trees.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/trees.pxd +15 -0
- sage/graphs/trees.pyx +310 -0
- sage/graphs/tutte_polynomial.py +713 -0
- sage/graphs/views.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/views.pyx +794 -0
- sage/graphs/weakly_chordal.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/graphs/weakly_chordal.pyx +604 -0
- sage/groups/all__sagemath_graphs.py +1 -0
- sage/groups/perm_gps/all__sagemath_graphs.py +1 -0
- sage/groups/perm_gps/partn_ref/all__sagemath_graphs.py +1 -0
- sage/groups/perm_gps/partn_ref/refinement_graphs.cpython-310-aarch64-linux-gnu.so +0 -0
- sage/groups/perm_gps/partn_ref/refinement_graphs.pxd +38 -0
- sage/groups/perm_gps/partn_ref/refinement_graphs.pyx +1666 -0
- sage/knots/all.py +6 -0
- sage/knots/free_knotinfo_monoid.py +507 -0
- sage/knots/gauss_code.py +291 -0
- sage/knots/knot.py +682 -0
- sage/knots/knot_table.py +284 -0
- sage/knots/knotinfo.py +2900 -0
- sage/knots/link.py +4715 -0
- sage/sandpiles/all.py +13 -0
- sage/sandpiles/examples.py +225 -0
- sage/sandpiles/sandpile.py +6365 -0
- sage/topology/all.py +22 -0
- sage/topology/cell_complex.py +1214 -0
- sage/topology/cubical_complex.py +1976 -0
- sage/topology/delta_complex.py +1806 -0
- sage/topology/filtered_simplicial_complex.py +744 -0
- sage/topology/moment_angle_complex.py +823 -0
- sage/topology/simplicial_complex.py +5160 -0
- sage/topology/simplicial_complex_catalog.py +92 -0
- sage/topology/simplicial_complex_examples.py +1680 -0
- sage/topology/simplicial_complex_homset.py +205 -0
- sage/topology/simplicial_complex_morphism.py +836 -0
- sage/topology/simplicial_set.py +4102 -0
- sage/topology/simplicial_set_catalog.py +55 -0
- sage/topology/simplicial_set_constructions.py +2954 -0
- sage/topology/simplicial_set_examples.py +865 -0
- sage/topology/simplicial_set_morphism.py +1464 -0
@@ -0,0 +1,797 @@
|
|
1
|
+
# sage_setup: distribution = sagemath-graphs
|
2
|
+
r"""
|
3
|
+
Backends for Sage (di)graphs
|
4
|
+
|
5
|
+
This module implements :class:`GenericGraphBackend` (the base class for
|
6
|
+
backends).
|
7
|
+
|
8
|
+
Any graph backend must redefine the following methods (for which
|
9
|
+
:class:`GenericGraphBackend` raises a :exc:`NotImplementedError`)
|
10
|
+
|
11
|
+
.. csv-table::
|
12
|
+
:class: contentstable
|
13
|
+
:widths: 30, 70
|
14
|
+
:delim: |
|
15
|
+
|
16
|
+
:meth:`~GenericGraphBackend.add_edge` | Add an edge `(u,v)` to ``self``, with label `l`.
|
17
|
+
:meth:`~GenericGraphBackend.add_edges` | Add a sequence of edges to ``self``.
|
18
|
+
:meth:`~GenericGraphBackend.add_vertex` | Add a labelled vertex to ``self``.
|
19
|
+
:meth:`~GenericGraphBackend.add_vertices` | Add labelled vertices to ``self``.
|
20
|
+
:meth:`~GenericGraphBackend.degree` | Return the total number of vertices incident to `v`.
|
21
|
+
:meth:`~GenericGraphBackend.in_degree` | Return the in-degree of `v`
|
22
|
+
:meth:`~GenericGraphBackend.out_degree` | Return the out-degree of `v`
|
23
|
+
:meth:`~GenericGraphBackend.del_edge` | Delete the edge `(u,v)` with label `l`.
|
24
|
+
:meth:`~GenericGraphBackend.del_vertex` | Delete a labelled vertex in ``self``.
|
25
|
+
:meth:`~GenericGraphBackend.del_vertices` | Delete labelled vertices in ``self``.
|
26
|
+
:meth:`~GenericGraphBackend.get_edge_label` | Return the edge label of `(u,v)`.
|
27
|
+
:meth:`~GenericGraphBackend.has_edge` | True if ``self`` has an edge `(u,v)` with label `l`.
|
28
|
+
:meth:`~GenericGraphBackend.has_vertex` | True if ``self`` has a vertex with label `v`.
|
29
|
+
:meth:`~GenericGraphBackend.iterator_edges` | Iterate over the edges incident to a sequence of vertices.
|
30
|
+
:meth:`~GenericGraphBackend.iterator_in_edges` | Iterate over the incoming edges incident to a sequence of vertices.
|
31
|
+
:meth:`~GenericGraphBackend.iterator_out_edges` | Iterate over the outbound edges incident to a sequence of vertices.
|
32
|
+
:meth:`~GenericGraphBackend.iterator_nbrs` | Iterate over the vertices adjacent to `v`.
|
33
|
+
:meth:`~GenericGraphBackend.iterator_in_nbrs` | Iterate over the in-neighbors of vertex `v`.
|
34
|
+
:meth:`~GenericGraphBackend.iterator_out_nbrs` | Iterate over the out-neighbors of vertex `v`.
|
35
|
+
:meth:`~GenericGraphBackend.iterator_verts` | Iterate over the vertices `v` with labels in verts.
|
36
|
+
:meth:`~GenericGraphBackend.loops` | Get/set whether or not ``self`` allows loops.
|
37
|
+
:meth:`~GenericGraphBackend.multiple_edges` | Get/set whether or not ``self`` allows multiple edges.
|
38
|
+
:meth:`~GenericGraphBackend.name` | Get/set name of ``self``.
|
39
|
+
:meth:`~GenericGraphBackend.num_edges` | The number of edges in ``self``
|
40
|
+
:meth:`~GenericGraphBackend.num_verts` | The number of vertices in ``self``
|
41
|
+
:meth:`~GenericGraphBackend.relabel` | Relabel the vertices of ``self`` by a permutation.
|
42
|
+
:meth:`~GenericGraphBackend.set_edge_label` | Label the edge `(u,v)` by `l`.
|
43
|
+
|
44
|
+
For an overview of graph data structures in sage, see
|
45
|
+
:mod:`~sage.graphs.base.overview`.
|
46
|
+
|
47
|
+
Classes and methods
|
48
|
+
-------------------
|
49
|
+
"""
|
50
|
+
# ****************************************************************************
|
51
|
+
# Copyright (C) 2008 Robert L. Miller <rlmillster@gmail.com>
|
52
|
+
# 2018 Julian Rüth <julian.rueth@fsfe.org>
|
53
|
+
#
|
54
|
+
# This program is free software: you can redistribute it and/or modify
|
55
|
+
# it under the terms of the GNU General Public License as published by
|
56
|
+
# the Free Software Foundation, either version 2 of the License, or
|
57
|
+
# (at your option) any later version.
|
58
|
+
# https://www.gnu.org/licenses/
|
59
|
+
# ****************************************************************************
|
60
|
+
from sage.graphs.base.c_graph cimport CGraphBackend
|
61
|
+
|
62
|
+
|
63
|
+
cdef class GenericGraphBackend(SageObject):
|
64
|
+
"""
|
65
|
+
A generic wrapper for the backend of a graph.
|
66
|
+
|
67
|
+
Various graph classes use extensions of this class. Note, this graph has a
|
68
|
+
number of placeholder functions, so the doctests are rather silly.
|
69
|
+
|
70
|
+
TESTS::
|
71
|
+
|
72
|
+
sage: import sage.graphs.base.graph_backends
|
73
|
+
"""
|
74
|
+
_loops = False
|
75
|
+
_multiple_edges = False
|
76
|
+
_name = ''
|
77
|
+
|
78
|
+
def add_edge(self, u, v, l, directed):
|
79
|
+
r"""
|
80
|
+
Add an edge `(u,v)` to ``self``, with label `l`.
|
81
|
+
|
82
|
+
If ``directed`` is ``True``, this is interpreted as an arc from `u` to
|
83
|
+
`v`.
|
84
|
+
|
85
|
+
INPUT:
|
86
|
+
|
87
|
+
- ``u``, ``v`` -- vertices
|
88
|
+
- ``l`` -- edge label
|
89
|
+
- ``directed`` -- boolean
|
90
|
+
|
91
|
+
TESTS::
|
92
|
+
|
93
|
+
sage: G = sage.graphs.base.graph_backends.GenericGraphBackend()
|
94
|
+
sage: G.add_edge(1,2,'a',True)
|
95
|
+
Traceback (most recent call last):
|
96
|
+
...
|
97
|
+
NotImplementedError
|
98
|
+
"""
|
99
|
+
raise NotImplementedError()
|
100
|
+
|
101
|
+
def add_edges(self, edges, directed):
|
102
|
+
"""
|
103
|
+
Add a sequence of edges to ``self``.
|
104
|
+
|
105
|
+
If ``directed`` is ``True``, these are interpreted as arcs.
|
106
|
+
|
107
|
+
INPUT:
|
108
|
+
|
109
|
+
- ``edges`` -- list/iterator of edges to be added
|
110
|
+
|
111
|
+
- ``directed`` -- boolean
|
112
|
+
|
113
|
+
TESTS::
|
114
|
+
|
115
|
+
sage: G = sage.graphs.base.graph_backends.GenericGraphBackend()
|
116
|
+
sage: G.add_edges([],True)
|
117
|
+
Traceback (most recent call last):
|
118
|
+
...
|
119
|
+
NotImplementedError
|
120
|
+
"""
|
121
|
+
raise NotImplementedError()
|
122
|
+
|
123
|
+
def add_vertex(self, name):
|
124
|
+
"""
|
125
|
+
Add a labelled vertex to ``self``.
|
126
|
+
|
127
|
+
INPUT:
|
128
|
+
|
129
|
+
- ``name`` -- vertex label
|
130
|
+
|
131
|
+
OUTPUT: if ``name=None``, the new vertex name is returned, ``None`` otherwise
|
132
|
+
|
133
|
+
TESTS::
|
134
|
+
|
135
|
+
sage: G = sage.graphs.base.graph_backends.GenericGraphBackend()
|
136
|
+
sage: G.add_vertex(0)
|
137
|
+
Traceback (most recent call last):
|
138
|
+
...
|
139
|
+
NotImplementedError
|
140
|
+
"""
|
141
|
+
raise NotImplementedError()
|
142
|
+
|
143
|
+
def add_vertices(self, vertices):
|
144
|
+
"""
|
145
|
+
Add labelled vertices to ``self``.
|
146
|
+
|
147
|
+
INPUT:
|
148
|
+
|
149
|
+
- ``vertices`` -- iterator of vertex labels; a new label is created,
|
150
|
+
used and returned in the output list for all ``None`` values in
|
151
|
+
``vertices``
|
152
|
+
|
153
|
+
OUTPUT:
|
154
|
+
|
155
|
+
Generated names of new vertices if there is at least one ``None`` value
|
156
|
+
present in ``vertices``. ``None`` otherwise.
|
157
|
+
|
158
|
+
EXAMPLES::
|
159
|
+
|
160
|
+
sage: G = sage.graphs.base.graph_backends.GenericGraphBackend()
|
161
|
+
sage: G.add_vertices([1,2,3])
|
162
|
+
Traceback (most recent call last):
|
163
|
+
...
|
164
|
+
NotImplementedError
|
165
|
+
"""
|
166
|
+
raise NotImplementedError()
|
167
|
+
|
168
|
+
def degree(self, v, directed):
|
169
|
+
r"""
|
170
|
+
Return the total number of vertices incident to `v`.
|
171
|
+
|
172
|
+
INPUT:
|
173
|
+
|
174
|
+
- ``v`` -- a vertex label
|
175
|
+
- ``directed`` -- boolean
|
176
|
+
|
177
|
+
OUTPUT: degree of `v`
|
178
|
+
|
179
|
+
TESTS::
|
180
|
+
|
181
|
+
sage: G = sage.graphs.base.graph_backends.GenericGraphBackend()
|
182
|
+
sage: G.degree(1, False)
|
183
|
+
Traceback (most recent call last):
|
184
|
+
...
|
185
|
+
NotImplementedError
|
186
|
+
"""
|
187
|
+
raise NotImplementedError()
|
188
|
+
|
189
|
+
def in_degree(self, v):
|
190
|
+
r"""
|
191
|
+
Return the in-degree of `v`.
|
192
|
+
|
193
|
+
INPUT:
|
194
|
+
|
195
|
+
- ``v`` -- a vertex label
|
196
|
+
|
197
|
+
TESTS::
|
198
|
+
|
199
|
+
sage: G = sage.graphs.base.graph_backends.GenericGraphBackend()
|
200
|
+
sage: G.in_degree(1)
|
201
|
+
Traceback (most recent call last):
|
202
|
+
...
|
203
|
+
NotImplementedError
|
204
|
+
"""
|
205
|
+
raise NotImplementedError()
|
206
|
+
|
207
|
+
def out_degree(self, v):
|
208
|
+
r"""
|
209
|
+
Return the out-degree of `v`.
|
210
|
+
|
211
|
+
INPUT:
|
212
|
+
|
213
|
+
- ``v`` -- a vertex label
|
214
|
+
|
215
|
+
TESTS::
|
216
|
+
|
217
|
+
sage: G = sage.graphs.base.graph_backends.GenericGraphBackend()
|
218
|
+
sage: G.out_degree(1)
|
219
|
+
Traceback (most recent call last):
|
220
|
+
...
|
221
|
+
NotImplementedError
|
222
|
+
"""
|
223
|
+
raise NotImplementedError()
|
224
|
+
|
225
|
+
def del_edge(self, u, v, l, directed):
|
226
|
+
r"""
|
227
|
+
Delete the edge `(u,v)` with label `l`.
|
228
|
+
|
229
|
+
INPUT:
|
230
|
+
|
231
|
+
- ``u``, ``v`` -- vertices
|
232
|
+
- ``l`` -- edge label
|
233
|
+
- ``directed`` -- boolean
|
234
|
+
|
235
|
+
TESTS::
|
236
|
+
|
237
|
+
sage: G = sage.graphs.base.graph_backends.GenericGraphBackend()
|
238
|
+
sage: G.del_edge(1,2,'a',True)
|
239
|
+
Traceback (most recent call last):
|
240
|
+
...
|
241
|
+
NotImplementedError
|
242
|
+
"""
|
243
|
+
raise NotImplementedError()
|
244
|
+
|
245
|
+
def del_vertex(self, v):
|
246
|
+
"""
|
247
|
+
Delete a labelled vertex in ``self``.
|
248
|
+
|
249
|
+
INPUT:
|
250
|
+
|
251
|
+
- ``v`` -- vertex label
|
252
|
+
|
253
|
+
TESTS::
|
254
|
+
|
255
|
+
sage: G = sage.graphs.base.graph_backends.GenericGraphBackend()
|
256
|
+
sage: G.del_vertex(0)
|
257
|
+
Traceback (most recent call last):
|
258
|
+
...
|
259
|
+
NotImplementedError
|
260
|
+
"""
|
261
|
+
raise NotImplementedError()
|
262
|
+
|
263
|
+
def del_vertices(self, vertices):
|
264
|
+
"""
|
265
|
+
Delete labelled vertices in ``self``.
|
266
|
+
|
267
|
+
INPUT:
|
268
|
+
|
269
|
+
- ``vertices`` -- iterator of vertex labels
|
270
|
+
|
271
|
+
TESTS::
|
272
|
+
|
273
|
+
sage: G = sage.graphs.base.graph_backends.GenericGraphBackend()
|
274
|
+
sage: G.del_vertices([1,2,3])
|
275
|
+
Traceback (most recent call last):
|
276
|
+
...
|
277
|
+
NotImplementedError
|
278
|
+
"""
|
279
|
+
raise NotImplementedError()
|
280
|
+
|
281
|
+
def get_edge_label(self, u, v):
|
282
|
+
r"""
|
283
|
+
Return the edge label of `(u, v)`.
|
284
|
+
|
285
|
+
INPUT:
|
286
|
+
|
287
|
+
- ``u``, ``v`` -- vertex labels
|
288
|
+
|
289
|
+
OUTPUT:
|
290
|
+
|
291
|
+
label of `(u,v)`
|
292
|
+
|
293
|
+
TESTS::
|
294
|
+
|
295
|
+
sage: G = sage.graphs.base.graph_backends.GenericGraphBackend()
|
296
|
+
sage: G.get_edge_label(1,2)
|
297
|
+
Traceback (most recent call last):
|
298
|
+
...
|
299
|
+
NotImplementedError
|
300
|
+
"""
|
301
|
+
raise NotImplementedError()
|
302
|
+
|
303
|
+
def has_edge(self, u, v, l):
|
304
|
+
r"""
|
305
|
+
Check whether ``self`` has an edge `(u,v)` with label `l`.
|
306
|
+
|
307
|
+
INPUT:
|
308
|
+
|
309
|
+
- ``u``, ``v`` -- vertex labels
|
310
|
+
- ``l`` -- label
|
311
|
+
|
312
|
+
OUTPUT: boolean
|
313
|
+
|
314
|
+
TESTS::
|
315
|
+
|
316
|
+
sage: G = sage.graphs.base.graph_backends.GenericGraphBackend()
|
317
|
+
sage: G.has_edge(1,2,'a')
|
318
|
+
Traceback (most recent call last):
|
319
|
+
...
|
320
|
+
NotImplementedError
|
321
|
+
"""
|
322
|
+
raise NotImplementedError()
|
323
|
+
|
324
|
+
def has_vertex(self, v):
|
325
|
+
r"""
|
326
|
+
Check whether ``self`` has a vertex with label `v`.
|
327
|
+
|
328
|
+
INPUT:
|
329
|
+
|
330
|
+
- ``v`` -- vertex label
|
331
|
+
|
332
|
+
OUTPUT: boolean
|
333
|
+
|
334
|
+
TESTS::
|
335
|
+
|
336
|
+
sage: G = sage.graphs.base.graph_backends.GenericGraphBackend()
|
337
|
+
sage: G.has_vertex(0)
|
338
|
+
Traceback (most recent call last):
|
339
|
+
...
|
340
|
+
NotImplementedError
|
341
|
+
"""
|
342
|
+
raise NotImplementedError()
|
343
|
+
|
344
|
+
def iterator_edges(self, vertices, labels):
|
345
|
+
"""
|
346
|
+
Iterate over the edges incident to a sequence of vertices.
|
347
|
+
|
348
|
+
Edges are assumed to be undirected.
|
349
|
+
|
350
|
+
This method returns an iterator over the edges `(u, v)` such that either
|
351
|
+
`u` or `v` is in ``vertices`` and the edge `(u, v)` is in ``self``.
|
352
|
+
|
353
|
+
INPUT:
|
354
|
+
|
355
|
+
- ``vertices`` -- list of vertex labels
|
356
|
+
- ``labels`` -- boolean
|
357
|
+
|
358
|
+
OUTPUT:
|
359
|
+
|
360
|
+
a generator which yields edges, with or without labels
|
361
|
+
depending on the labels parameter.
|
362
|
+
|
363
|
+
TESTS::
|
364
|
+
|
365
|
+
sage: G = sage.graphs.base.graph_backends.GenericGraphBackend()
|
366
|
+
sage: G.iterator_edges([],True)
|
367
|
+
Traceback (most recent call last):
|
368
|
+
...
|
369
|
+
NotImplementedError
|
370
|
+
"""
|
371
|
+
raise NotImplementedError()
|
372
|
+
|
373
|
+
def iterator_in_edges(self, vertices, labels):
|
374
|
+
"""
|
375
|
+
Iterate over the incoming edges incident to a sequence of vertices.
|
376
|
+
|
377
|
+
This method returns an iterator over the edges `(u, v)` such that `v` is
|
378
|
+
in ``vertices`` and the edge `(u, v)` is in ``self``.
|
379
|
+
|
380
|
+
INPUT:
|
381
|
+
|
382
|
+
- ``vertices`` -- list of vertex labels
|
383
|
+
- ``labels`` -- boolean
|
384
|
+
|
385
|
+
OUTPUT: a generator which yields edges, with or without labels
|
386
|
+
depending on the labels parameter
|
387
|
+
|
388
|
+
TESTS::
|
389
|
+
|
390
|
+
sage: G = sage.graphs.base.graph_backends.GenericGraphBackend()
|
391
|
+
sage: G.iterator_in_edges([],True)
|
392
|
+
Traceback (most recent call last):
|
393
|
+
...
|
394
|
+
NotImplementedError
|
395
|
+
"""
|
396
|
+
raise NotImplementedError()
|
397
|
+
|
398
|
+
def iterator_out_edges(self, vertices, labels):
|
399
|
+
"""
|
400
|
+
Iterate over the outbound edges incident to a sequence of vertices.
|
401
|
+
|
402
|
+
This method returns an iterator over the edges `(v, u)` such that `v` is
|
403
|
+
in ``vertices`` and the edge `(v, u)` is in ``self``.
|
404
|
+
|
405
|
+
INPUT:
|
406
|
+
|
407
|
+
- ``vertices`` -- list of vertex labels
|
408
|
+
- ``labels`` -- boolean
|
409
|
+
|
410
|
+
OUTPUT:
|
411
|
+
|
412
|
+
a generator which yields edges, with or without labels depending on
|
413
|
+
the labels parameter.
|
414
|
+
|
415
|
+
TESTS::
|
416
|
+
|
417
|
+
sage: G = sage.graphs.base.graph_backends.GenericGraphBackend()
|
418
|
+
sage: G.iterator_out_edges([],True)
|
419
|
+
Traceback (most recent call last):
|
420
|
+
...
|
421
|
+
NotImplementedError
|
422
|
+
"""
|
423
|
+
raise NotImplementedError()
|
424
|
+
|
425
|
+
def iterator_nbrs(self, v):
|
426
|
+
r"""
|
427
|
+
Iterate over the vertices adjacent to `v`.
|
428
|
+
|
429
|
+
This method returns an iterator over the vertices `u` such that either
|
430
|
+
the edge `(u, v)` or the edge `(v, u)` is in ``self`` (that is,
|
431
|
+
neighbors of `v`).
|
432
|
+
|
433
|
+
INPUT:
|
434
|
+
|
435
|
+
- ``v`` -- vertex label
|
436
|
+
|
437
|
+
OUTPUT: a generator which yields vertex labels
|
438
|
+
|
439
|
+
TESTS::
|
440
|
+
|
441
|
+
sage: G = sage.graphs.base.graph_backends.GenericGraphBackend()
|
442
|
+
sage: G.iterator_nbrs(0)
|
443
|
+
Traceback (most recent call last):
|
444
|
+
...
|
445
|
+
NotImplementedError
|
446
|
+
"""
|
447
|
+
raise NotImplementedError()
|
448
|
+
|
449
|
+
def iterator_in_nbrs(self, v):
|
450
|
+
r"""
|
451
|
+
Iterate over the in-neighbors of vertex `v`.
|
452
|
+
|
453
|
+
This method returns an iterator over the vertices `u` such that the edge
|
454
|
+
`(u, v)` is in ``self`` (that is, predecessors of `v`).
|
455
|
+
|
456
|
+
INPUT:
|
457
|
+
|
458
|
+
- ``v`` -- vertex label
|
459
|
+
|
460
|
+
OUTPUT: a generator which yields vertex labels
|
461
|
+
|
462
|
+
TESTS::
|
463
|
+
|
464
|
+
sage: G = sage.graphs.base.graph_backends.GenericGraphBackend()
|
465
|
+
sage: G.iterator_in_nbrs(0)
|
466
|
+
Traceback (most recent call last):
|
467
|
+
...
|
468
|
+
NotImplementedError
|
469
|
+
"""
|
470
|
+
raise NotImplementedError()
|
471
|
+
|
472
|
+
def iterator_out_nbrs(self, v):
|
473
|
+
r"""
|
474
|
+
Iterate over the out-neighbors of `v`.
|
475
|
+
|
476
|
+
This method returns an iterator over the vertices `u` such that the edge
|
477
|
+
`(v, u)` is in ``self`` (that is, successors of `v`).
|
478
|
+
|
479
|
+
INPUT:
|
480
|
+
|
481
|
+
- ``v`` -- vertex label
|
482
|
+
|
483
|
+
OUTPUT: a generator which yields vertex labels
|
484
|
+
|
485
|
+
TESTS::
|
486
|
+
|
487
|
+
sage: G = sage.graphs.base.graph_backends.GenericGraphBackend()
|
488
|
+
sage: G.iterator_out_nbrs(0)
|
489
|
+
Traceback (most recent call last):
|
490
|
+
...
|
491
|
+
NotImplementedError
|
492
|
+
"""
|
493
|
+
raise NotImplementedError()
|
494
|
+
|
495
|
+
def iterator_verts(self, verts):
|
496
|
+
r"""
|
497
|
+
Iterate over the vertices `v` with labels in ``verts``.
|
498
|
+
|
499
|
+
INPUT:
|
500
|
+
|
501
|
+
- ``verts`` -- vertex labels
|
502
|
+
|
503
|
+
OUTPUT: a generator which yields vertices
|
504
|
+
|
505
|
+
TESTS::
|
506
|
+
|
507
|
+
sage: G = sage.graphs.base.graph_backends.GenericGraphBackend()
|
508
|
+
sage: G.iterator_verts(0)
|
509
|
+
Traceback (most recent call last):
|
510
|
+
...
|
511
|
+
NotImplementedError
|
512
|
+
"""
|
513
|
+
raise NotImplementedError()
|
514
|
+
|
515
|
+
def loops(self, new=None):
|
516
|
+
"""
|
517
|
+
Get/set whether or not ``self`` allows loops.
|
518
|
+
|
519
|
+
INPUT:
|
520
|
+
|
521
|
+
- ``new`` -- can be a boolean (in which case it sets the value) or
|
522
|
+
``None``, in which case the current value is returned. It is set to
|
523
|
+
``None`` by default.
|
524
|
+
|
525
|
+
TESTS::
|
526
|
+
|
527
|
+
sage: G = sage.graphs.base.graph_backends.GenericGraphBackend()
|
528
|
+
sage: G.loops(True)
|
529
|
+
Traceback (most recent call last):
|
530
|
+
...
|
531
|
+
NotImplementedError
|
532
|
+
sage: G.loops(None)
|
533
|
+
Traceback (most recent call last):
|
534
|
+
...
|
535
|
+
NotImplementedError
|
536
|
+
"""
|
537
|
+
raise NotImplementedError()
|
538
|
+
|
539
|
+
def multiple_edges(self, new=None):
|
540
|
+
"""
|
541
|
+
Get/set whether or not ``self`` allows multiple edges.
|
542
|
+
|
543
|
+
INPUT:
|
544
|
+
|
545
|
+
- ``new`` -- can be a boolean (in which case it sets the value) or
|
546
|
+
``None``, in which case the current value is returned. It is set to
|
547
|
+
``None`` by default.
|
548
|
+
|
549
|
+
TESTS::
|
550
|
+
|
551
|
+
sage: G = sage.graphs.base.graph_backends.GenericGraphBackend()
|
552
|
+
sage: G.multiple_edges(True)
|
553
|
+
Traceback (most recent call last):
|
554
|
+
...
|
555
|
+
NotImplementedError
|
556
|
+
sage: G.multiple_edges(None)
|
557
|
+
Traceback (most recent call last):
|
558
|
+
...
|
559
|
+
NotImplementedError
|
560
|
+
"""
|
561
|
+
raise NotImplementedError()
|
562
|
+
|
563
|
+
def name(self, new=None):
|
564
|
+
"""
|
565
|
+
Get/set name of ``self``.
|
566
|
+
|
567
|
+
INPUT:
|
568
|
+
|
569
|
+
- ``new`` -- can be a string (in which case it sets the value) or
|
570
|
+
``None``, in which case the current value is returned. It is set to
|
571
|
+
``None`` by default.
|
572
|
+
|
573
|
+
TESTS::
|
574
|
+
|
575
|
+
sage: G = sage.graphs.base.graph_backends.GenericGraphBackend()
|
576
|
+
sage: G.name("A Generic Graph")
|
577
|
+
Traceback (most recent call last):
|
578
|
+
...
|
579
|
+
NotImplementedError
|
580
|
+
sage: G.name(None)
|
581
|
+
Traceback (most recent call last):
|
582
|
+
...
|
583
|
+
NotImplementedError
|
584
|
+
"""
|
585
|
+
raise NotImplementedError()
|
586
|
+
|
587
|
+
def num_edges(self, directed):
|
588
|
+
"""
|
589
|
+
Return the number of edges in ``self``.
|
590
|
+
|
591
|
+
INPUT:
|
592
|
+
|
593
|
+
- ``directed`` -- boolean
|
594
|
+
|
595
|
+
TESTS::
|
596
|
+
|
597
|
+
sage: G = sage.graphs.base.graph_backends.GenericGraphBackend()
|
598
|
+
sage: G.num_edges(True)
|
599
|
+
Traceback (most recent call last):
|
600
|
+
...
|
601
|
+
NotImplementedError
|
602
|
+
sage: G.num_edges(False)
|
603
|
+
Traceback (most recent call last):
|
604
|
+
...
|
605
|
+
NotImplementedError
|
606
|
+
"""
|
607
|
+
raise NotImplementedError()
|
608
|
+
|
609
|
+
def num_verts(self):
|
610
|
+
"""
|
611
|
+
Return the number of vertices in ``self``.
|
612
|
+
|
613
|
+
TESTS::
|
614
|
+
|
615
|
+
sage: G = sage.graphs.base.graph_backends.GenericGraphBackend()
|
616
|
+
sage: G.num_verts()
|
617
|
+
Traceback (most recent call last):
|
618
|
+
...
|
619
|
+
NotImplementedError
|
620
|
+
"""
|
621
|
+
raise NotImplementedError()
|
622
|
+
|
623
|
+
def relabel(self, perm, directed):
|
624
|
+
"""
|
625
|
+
Relabel the vertices of ``self`` by a permutation.
|
626
|
+
|
627
|
+
INPUT:
|
628
|
+
|
629
|
+
- ``perm`` -- permutation
|
630
|
+
- ``directed`` -- boolean
|
631
|
+
|
632
|
+
TESTS::
|
633
|
+
|
634
|
+
sage: G = sage.graphs.base.graph_backends.GenericGraphBackend()
|
635
|
+
sage: G.relabel([],False)
|
636
|
+
Traceback (most recent call last):
|
637
|
+
...
|
638
|
+
NotImplementedError
|
639
|
+
"""
|
640
|
+
raise NotImplementedError()
|
641
|
+
|
642
|
+
def set_edge_label(self, u, v, l, directed):
|
643
|
+
r"""
|
644
|
+
Label the edge `(u,v)` by `l`.
|
645
|
+
|
646
|
+
INPUT:
|
647
|
+
|
648
|
+
- ``u``, ``v`` -- vertices
|
649
|
+
- ``l`` -- edge label
|
650
|
+
- ``directed`` -- boolean
|
651
|
+
|
652
|
+
TESTS::
|
653
|
+
|
654
|
+
sage: G = sage.graphs.base.graph_backends.GenericGraphBackend()
|
655
|
+
sage: G.set_edge_label(1,2,'a',True)
|
656
|
+
Traceback (most recent call last):
|
657
|
+
...
|
658
|
+
NotImplementedError
|
659
|
+
"""
|
660
|
+
raise NotImplementedError()
|
661
|
+
|
662
|
+
def __reduce__(self):
|
663
|
+
r"""
|
664
|
+
Return a tuple used for pickling this graph.
|
665
|
+
|
666
|
+
OUTPUT:
|
667
|
+
|
668
|
+
This function returns a pair ``(f, args)`` such that ``f(*args)``
|
669
|
+
produces a copy of ``self``. The function returned is always
|
670
|
+
:func:`unpickle_graph_backend`.
|
671
|
+
|
672
|
+
EXAMPLES:
|
673
|
+
|
674
|
+
Pickling of the static graph backend makes pickling of immutable
|
675
|
+
graphs and digraphs work::
|
676
|
+
|
677
|
+
sage: G = Graph(graphs.PetersenGraph(), immutable=True)
|
678
|
+
sage: G == loads(dumps(G))
|
679
|
+
True
|
680
|
+
sage: uc = [[2, 3], [], [1], [1], [1], [3, 4]]
|
681
|
+
sage: D = DiGraph({i: uc[i] for i in range(len(uc))}, immutable=True)
|
682
|
+
sage: loads(dumps(D)) == D
|
683
|
+
True
|
684
|
+
|
685
|
+
No problems with loops and multiple edges, with Labels::
|
686
|
+
|
687
|
+
sage: g = Graph(multiedges=True, loops=True)
|
688
|
+
sage: g.add_edges(2 * graphs.PetersenGraph().edges(sort=False))
|
689
|
+
sage: g.add_edge(0, 0)
|
690
|
+
sage: g.add_edge(1, 1, "a label")
|
691
|
+
sage: g.add_edges([(0, 1, "labellll"), (0, 1, "labellll"), (0, 1, "LABELLLL")])
|
692
|
+
sage: g.add_vertex("isolated vertex")
|
693
|
+
sage: gi = g.copy(immutable=True)
|
694
|
+
sage: loads(dumps(gi)) == gi
|
695
|
+
True
|
696
|
+
|
697
|
+
Similar, with a directed graph::
|
698
|
+
|
699
|
+
sage: g = DiGraph(multiedges=True, loops=True)
|
700
|
+
sage: H = 2 * (digraphs.Circuit(15) + DiGraph(graphs.PetersenGraph()))
|
701
|
+
sage: g.add_edges(H.edge_iterator())
|
702
|
+
sage: g.add_edge(0, 0)
|
703
|
+
sage: g.add_edge(1, 1, "a label")
|
704
|
+
sage: g.add_edges([(0, 1, "labellll"), (0, 1, "labellll"), (0, 1, "LABELLLL")])
|
705
|
+
sage: g.add_vertex("isolated vertex")
|
706
|
+
sage: gi = g.copy(immutable=True)
|
707
|
+
sage: loads(dumps(gi)) == gi
|
708
|
+
True
|
709
|
+
|
710
|
+
TESTS:
|
711
|
+
|
712
|
+
Check that :issue:`38900` is fixed::
|
713
|
+
|
714
|
+
sage: from itertools import product
|
715
|
+
sage: for sparse, immutable in product([True, False], [True, False]):
|
716
|
+
....: G = Graph([[0, 1, 2], [(0, 1)]], sparse=sparse, immutable=immutable)
|
717
|
+
....: H = loads(dumps(G))
|
718
|
+
....: if type(G._backend) != type(H._backend):
|
719
|
+
....: print(sparse, immutable, type(G._backend), type(H._backend))
|
720
|
+
"""
|
721
|
+
from sage.graphs.base.static_sparse_backend import StaticSparseBackend
|
722
|
+
from sage.graphs.base.sparse_graph import SparseGraphBackend
|
723
|
+
from sage.graphs.base.dense_graph import DenseGraphBackend
|
724
|
+
|
725
|
+
# data_structure, multiedges, directed, loops
|
726
|
+
if isinstance(self, CGraphBackend):
|
727
|
+
if isinstance(self, SparseGraphBackend):
|
728
|
+
data_structure = "sparse"
|
729
|
+
elif isinstance(self, DenseGraphBackend):
|
730
|
+
data_structure = "dense"
|
731
|
+
elif isinstance(self, StaticSparseBackend):
|
732
|
+
data_structure = "static_sparse"
|
733
|
+
else:
|
734
|
+
raise Exception
|
735
|
+
multiedges = (<CGraphBackend> self)._multiple_edges
|
736
|
+
directed = (<CGraphBackend> self)._directed
|
737
|
+
loops = (<CGraphBackend> self)._loops
|
738
|
+
else:
|
739
|
+
raise Exception
|
740
|
+
|
741
|
+
# Vertices and edges
|
742
|
+
vertices = list(self.iterator_verts(None))
|
743
|
+
if directed:
|
744
|
+
edges = list(self.iterator_out_edges(vertices, True))
|
745
|
+
else:
|
746
|
+
edges = list(self.iterator_edges(vertices, True))
|
747
|
+
|
748
|
+
return (unpickle_graph_backend,
|
749
|
+
(directed, vertices, edges,
|
750
|
+
{'loops': loops,
|
751
|
+
'multiedges': multiedges,
|
752
|
+
'data_structure': data_structure}))
|
753
|
+
|
754
|
+
|
755
|
+
def unpickle_graph_backend(directed, vertices, edges, kwds):
|
756
|
+
r"""
|
757
|
+
Return a backend from its pickled data.
|
758
|
+
|
759
|
+
This methods is defined because Python's pickling mechanism can only build
|
760
|
+
objects from a pair ``(f,args)`` by running ``f(*args)``. In particular,
|
761
|
+
there is apparently no way to define a ``**kwargs`` (i.e. define the value
|
762
|
+
of keyword arguments of ``f``), which means that one must know the order of
|
763
|
+
all arguments of ``f`` (here, ``f`` is :class:`Graph` or :class:`DiGraph`).
|
764
|
+
|
765
|
+
As a consequence, this means that the order cannot change in the future,
|
766
|
+
which is something we cannot swear.
|
767
|
+
|
768
|
+
INPUT:
|
769
|
+
|
770
|
+
- ``directed`` -- boolean
|
771
|
+
|
772
|
+
- ``vertices`` -- list of vertices
|
773
|
+
|
774
|
+
- ``edges`` -- list of edges
|
775
|
+
|
776
|
+
- ``kwds`` -- any dictionary whose keywords will be forwarded to the graph
|
777
|
+
constructor
|
778
|
+
|
779
|
+
This function builds a :class:`Graph` or :class:`DiGraph` from its data, and
|
780
|
+
returns the ``_backend`` attribute of this object.
|
781
|
+
|
782
|
+
EXAMPLES::
|
783
|
+
|
784
|
+
sage: from sage.graphs.base.graph_backends import unpickle_graph_backend
|
785
|
+
sage: b = unpickle_graph_backend(0, [0, 1, 2, 3], [(0, 3, 'label'), (0, 0, 1)], {'loops': True})
|
786
|
+
sage: b
|
787
|
+
<sage.graphs.base.sparse_graph.SparseGraphBackend object at ...>
|
788
|
+
sage: list(b.iterator_edges(range(4), True))
|
789
|
+
[(0, 0, 1), (0, 3, 'label')]
|
790
|
+
"""
|
791
|
+
if directed:
|
792
|
+
from sage.graphs.digraph import DiGraph as constructor
|
793
|
+
else:
|
794
|
+
from sage.graphs.graph import Graph as constructor
|
795
|
+
|
796
|
+
G = constructor(data=[vertices, edges], format='vertices_and_edges', **kwds)
|
797
|
+
return G._backend
|