Opened 4 years ago

Closed 4 years ago

#27127 closed enhancement (fixed)

py3: avoid .vertices() in method ear_decomposition

Reported by: David Coudert Owned by:
Priority: major Milestone: sage-8.7
Component: graph theory Keywords: py3, graph
Cc: Merged in:
Authors: David Coudert Reviewers: Travis Scrimshaw
Report Upstream: N/A Work issues:
Branch: 8f382df (Commits, GitHub, GitLab) Commit: 8f382df077017468f9a135e066c34015ae4bf5ab
Dependencies: Stopgaps:

Status badges

Description

We avoid using .vertices() in this method and fix a failing doctest for py3.

Change History (5)

comment:1 Changed 4 years ago by David Coudert

Branch: public/27127_ear_decomposition
Commit: 8f382df077017468f9a135e066c34015ae4bf5ab
Status: newneeds_review

New commits:

8f382dftrac #27127: avoid .vertices() in ear_decomposition

comment:2 Changed 4 years ago by Travis Scrimshaw

Why this change:

-            sage: g = graphs.CubeGraph(2)
+            sage: g = graphs.CycleGraph(4)
             sage: g.ear_decomposition()
-            [['00', '01', '11', '10', '00']]
+            [[0, 3, 2, 1, 0]]

comment:3 Changed 4 years ago by David Coudert

This change is independent of using .vertices() or not. This doctest was failing with py3. My understanding is that neighbors of a vertex are visited in different orders in py2 and py3 as the order in which elements of a set are listed might differ (see G._backend.iterator_nbrs??). Here, if the first visited neighbor of '00' is '01' or '10', we get different answers. With py3 we get [['00', '10', '11', '01', '00']] and so the doctest was failing.

Using CycleGraph(4), the doctest is more stable and we get the same answer with py2 and py3. CubeGraph(2) is a cycle of order 4, so it's essentially the same test.

comment:4 Changed 4 years ago by Travis Scrimshaw

Reviewers: Travis Scrimshaw
Status: needs_reviewpositive_review

I don't think it is any more stable of a test, just something that happens to work on both. Anyways, this is okay with me since there is not such an easy way out of this.

comment:5 Changed 4 years ago by Volker Braun

Branch: public/27127_ear_decomposition8f382df077017468f9a135e066c34015ae4bf5ab
Resolution: fixed
Status: positive_reviewclosed
Note: See TracTickets for help on using tickets.