diff --git a/.gitignore b/.gitignore index 51cf481afa1..d408cdcfe66 100644 --- a/.gitignore +++ b/.gitignore @@ -462,6 +462,7 @@ src/sage/graphs/graph_decompositions/__init__.py src/sage/graphs/generators/__init__.py src/sage/graphs/__init__.py src/sage/graphs/base/__init__.py +src/sage/graphs/tests/__init__.py src/sage/databases/__init__.py src/sage/stats/hmm/__init__.py src/sage/stats/__init__.py diff --git a/meson.build b/meson.build index e470de6ab1f..78cd1f42962 100755 --- a/meson.build +++ b/meson.build @@ -195,6 +195,7 @@ file_paths = [ 'src/sage/graphs/generators/__init__.py', 'src/sage/graphs/__init__.py', 'src/sage/graphs/base/__init__.py', + 'src/sage/graphs/tests/__init__.py', 'src/sage/databases/__init__.py', 'src/sage/stats/hmm/__init__.py', 'src/sage/stats/__init__.py', diff --git a/src/sage/graphs/generators/smallgraphs.py b/src/sage/graphs/generators/smallgraphs.py index 5c596626125..cd177a99de5 100644 --- a/src/sage/graphs/generators/smallgraphs.py +++ b/src/sage/graphs/generators/smallgraphs.py @@ -4189,6 +4189,7 @@ def PetersenGraph(): from sage.graphs.generators.families import GeneralizedPetersenGraph P = GeneralizedPetersenGraph(5, 2) P.name("Petersen graph") + P.is_projective_planar.set_cache(True) return P diff --git a/src/sage/graphs/graph.py b/src/sage/graphs/graph.py index 41fdabd442f..0891e931670 100644 --- a/src/sage/graphs/graph.py +++ b/src/sage/graphs/graph.py @@ -428,6 +428,7 @@ from sage.parallel.decorate import parallel from sage.misc.lazy_import import lazy_import, LazyImport from sage.features.mcqd import Mcqd +from sage.misc.cachefunc import cached_method lazy_import('sage.graphs.mcqd', ['mcqd'], feature=Mcqd()) @@ -9501,6 +9502,7 @@ def bipartite_double(self, extended=False): G.name("%sBipartite Double of %s" % (prefix, self.name())) return G + @cached_method @doc_index("Graph properties") def is_projective_planar(self, return_map=False): r""" @@ -9528,7 +9530,7 @@ def is_projective_planar(self, return_map=False): The Petersen graph is a known projective planar graph:: sage: P = graphs.PetersenGraph() - sage: P.is_projective_planar() # long time + sage: P.is_projective_planar() True `K_{4,4}` has a projective plane crossing number of 2. One of the diff --git a/src/sage/graphs/meson.build b/src/sage/graphs/meson.build index 47d8544d1dd..ce3c85c8cf0 100644 --- a/src/sage/graphs/meson.build +++ b/src/sage/graphs/meson.build @@ -91,6 +91,7 @@ py.install_sources( subdir: 'sage/graphs', ) + extension_data = { 'asteroidal_triples' : files('asteroidal_triples.pyx'), 'centrality' : files('centrality.pyx'), @@ -178,3 +179,4 @@ py.extension_module( subdir('base') subdir('generators') subdir('graph_decompositions') +subdir('tests') diff --git a/src/sage/graphs/tests/is_projective_planar_test.py b/src/sage/graphs/tests/is_projective_planar_test.py new file mode 100644 index 00000000000..5f28e3465a8 --- /dev/null +++ b/src/sage/graphs/tests/is_projective_planar_test.py @@ -0,0 +1,13 @@ +import pytest + + +def test_petersen_graph_is_projective_planar(): + r""" + Ensure that the Petersen graph is projective planar without + using the cache. + """ + from sage.graphs.generators.smallgraphs import PetersenGraph + P = PetersenGraph() + P.is_projective_planar.clear_cache() + assert not P.is_projective_planar.is_in_cache() + assert P.is_projective_planar() diff --git a/src/sage/graphs/tests/meson.build b/src/sage/graphs/tests/meson.build new file mode 100644 index 00000000000..b51e221a723 --- /dev/null +++ b/src/sage/graphs/tests/meson.build @@ -0,0 +1,5 @@ +py.install_sources( + '__init__.py', + 'is_projective_planar_test.py', + subdir: 'sage/graphs/tests', +)