Opened 4 years ago

Closed 4 years ago

# py3: avoid .vertices() in method ear_decomposition

Reported by: Owned by: David Coudert major sage-8.7 graph theory py3, graph David Coudert Travis Scrimshaw N/A 8f382df 8f382df077017468f9a135e066c34015ae4bf5ab

### Description

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

### comment:1 Changed 4 years ago by David Coudert

Branch: → public/27127_ear_decomposition → 8f382df077017468f9a135e066c34015ae4bf5ab new → needs_review

New commits:

 ​8f382df `trac #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 needs_review → positive_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_decomposition → 8f382df077017468f9a135e066c34015ae4bf5ab → fixed positive_review → closed
Note: See TracTickets for help on using tickets.