Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
fixing is_gallai_tree
Browse files Browse the repository at this point in the history
  • Loading branch information
Frédéric Chapoton committed Jun 22, 2018
1 parent 8a6bc91 commit f8a9c73
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/sage/graphs/generic_graph.py
Expand Up @@ -12671,7 +12671,7 @@ def is_interval(self, certificate=False):

def is_gallai_tree(self):
r"""
Returns whether the current graph is a Gallai tree.
Return whether the current graph is a Gallai tree.

A graph is a Gallai tree if and only if it is
connected and its `2`-connected components are all
Expand Down Expand Up @@ -12709,15 +12709,24 @@ def is_gallai_tree(self):
sage: g.add_edges([(-1,c[0]) for c in g.connected_components()])
sage: g.is_gallai_tree()
True

TESTS:

Check that :trac:`25613` is fixed::

sage: g = graphs.CycleGraph(5)
sage: g.add_edge(0,5)
sage: g.is_gallai_tree()
True
"""
self._scream_if_not_simple()
if not self.is_connected():
return False

for c in self.blocks_and_cut_vertices()[0]:
gg = self.subgraph(c)
# is it an odd cycle ? a complete graph ?
if not ( (len(c)%2 == 1 and gg.size() == len(c)+1) or gg.is_clique() ):
# is it an odd cycle ? a complete graph ?
if not ((len(c) % 2 and gg.size() == len(c)) or gg.is_clique()):
return False

return True
Expand Down

0 comments on commit f8a9c73

Please sign in to comment.