Opened 4 years ago

Closed 4 years ago

#26666 closed enhancement (fixed)

clean generic_graph.py (part 9) - edge and vertex handlers

Reported by: David Coudert Owned by:
Priority: major Milestone: sage-8.5
Component: graph theory Keywords: py3, graph
Cc: Travis Scrimshaw, Frédéric Chapoton Merged in:
Authors: David Coudert Reviewers: Travis Scrimshaw
Report Upstream: N/A Work issues:
Branch: 1c43e4e (Commits, GitHub, GitLab) Commit: 1c43e4ea526f3edb42304c3a170ea402da7b1695
Dependencies: Stopgaps:

Status badges

Description

In this ticket, we clean methods for adding/removing vertices/edges and enumerating neighbors. The main changes are:

  • add parameter sort to method .vertices. This gives an alternative to list(G).
  • in method delete_vertices, we add as first instruction vertices = list(vertices). This way we now allow to call this method with an iterator. Before, the method was not removing any vertex when called with an iterator. This will certainly help reducing further the number of calls to .vertices().
  • in method vertex_iterator, we remove doctests related to former networkx backend
  • change in method remove_multiple_edges that should make it faster
  • PEP8 cleaning

Change History (12)

comment:1 Changed 4 years ago by David Coudert

Branch: public/26666_generic_graph_part_9_edge_and_vertex
Cc: Travis Scrimshaw Frédéric Chapoton added
Commit: 0070906a5ddd0d72c2f5d082bb70da65744bdd9c
Keywords: py3 graph added
Status: newneeds_review

New commits:

0070906trac #26666: generic_graph.py (part 9) - edge and vertex handlers

comment:2 Changed 4 years ago by Frédéric Chapoton

2 trivial failing doctests in src/sage/graphs/bipartite_graph.py

comment:3 Changed 4 years ago by git

Commit: 0070906a5ddd0d72c2f5d082bb70da65744bdd9cecfc5c669e49deb9eb0bca906b25764b3f9a8925

Branch pushed to git repo; I updated commit sha1. New commits:

7131aaatrac #26666: fix doc
ecfc5c6trac #26666: fix doctests in bipartite_graph.py

comment:4 Changed 4 years ago by David Coudert

oups, fixed.

comment:5 Changed 4 years ago by David Coudert

Summary: clean connectivity.pyx (part 9) - edge and vertex handlersclean generic_graph.py (part 9) - edge and vertex handlers

comment:6 Changed 4 years ago by git

Commit: ecfc5c669e49deb9eb0bca906b25764b3f9a892544c76f2e457f94ab0331a09ef6c924a63fd0d60e

Branch pushed to git repo; I updated commit sha1. New commits:

44c76f2trac #26666: avoid .vertices() in method clear

comment:7 Changed 4 years ago by David Coudert

We also avoid sorting vertices before removing them from the graph.

comment:8 Changed 4 years ago by Travis Scrimshaw

Just for clarity, I think it is better to add these parentheses: if (not sort) and key:

Since u and v are code inputs for the one-line descriptions, I think it would be better to do

-Delete all edges from `u` to `v`.
+Delete all edges from ``u`` to ``v``.

I think the OUTPUT: block for has_vertex is functionally useless and can be safely removed (it is essentially a copy of the one-line description).

Other than that LGTM.

comment:9 Changed 4 years ago by git

Commit: 44c76f2e457f94ab0331a09ef6c924a63fd0d60e1c43e4ea526f3edb42304c3a170ea402da7b1695

Branch pushed to git repo; I updated commit sha1. New commits:

1c43e4etrac #26666: implement reviewer's comments

comment:10 Changed 4 years ago by David Coudert

i have implemented all you comments. Should be better now.

comment:11 Changed 4 years ago by Travis Scrimshaw

Reviewers: Travis Scrimshaw
Status: needs_reviewpositive_review

Thanks. LGTM.

comment:12 Changed 4 years ago by Volker Braun

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