Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean graph.py #26432

Closed
dcoudert opened this issue Oct 7, 2018 · 27 comments
Closed

clean graph.py #26432

dcoudert opened this issue Oct 7, 2018 · 27 comments

Comments

@dcoudert
Copy link
Contributor

dcoudert commented Oct 7, 2018

We do as much cleaning as possible: alignments, PEP8, avoid many vertex comparisons or sorting, etc.

CC: @tscrim @fchapoton

Component: graph theory

Author: David Coudert

Branch/Commit: 20bf46b

Reviewer: Travis Scrimshaw

Issue created by migration from https://trac.sagemath.org/ticket/26432

@dcoudert dcoudert added this to the sage-8.4 milestone Oct 7, 2018
@dcoudert
Copy link
Contributor Author

dcoudert commented Oct 7, 2018

Commit: 9067797

@dcoudert
Copy link
Contributor Author

dcoudert commented Oct 7, 2018

New commits:

9067797trac #26432: first round of improvements

@dcoudert
Copy link
Contributor Author

dcoudert commented Oct 7, 2018

Branch: u/dcoudert/26432_clean_graph_py

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 7, 2018

Changed commit from 9067797 to 672b173

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 7, 2018

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

672b173trac #26432: more improvements

@dcoudert

This comment has been minimized.

@dcoudert
Copy link
Contributor Author

dcoudert commented Oct 7, 2018

comment:3

So far, remaining issues are:

  • sorting of output in cliques_maximal and vertex_cover. Should we put a deprecation ? (could be done in a specific ticket)
  • sorting in examples of cliques_number_of, cliques_vertex_clique_number, cliques_containing_vertex. This can be changed here.
  • recursion on method DFS of ear_decomposition. I can do it here or in specific ticket.

Any advise is more than welcome.

@jhpalmieri
Copy link
Member

comment:4

Edit: sorry, I was wrong about this. It does not help with the homology doctests.

@tscrim
Copy link
Collaborator

tscrim commented Oct 8, 2018

comment:5

Small things that I think should be fixed before a positive review:

sorted(V.keys()) -> sorted(V).

While I understand why, it still looks ugly

+        A snark has chromatic index 4 hence its line graph has chromatic number
+        4::

probably better to also move down number and maybe also chromatic.

The bullet points are over-indented:

         Here are two very simple modules :
 
-            * A connected component `C` (or the union of some --but
-              not all-- of them) of a disconnected graph `G`, for
-              instance, is a module, as no vertex of `C` has a
-              neighbor outside of it.
+            * A connected component `C` (or the union of some --but not all-- of
+              them) of a disconnected graph `G`, for instance, is a module, as
+              no vertex of `C` has a neighbor outside of it.
 
-            * An anticomponent `C` (or the union of some --but not
-              all-- of them) of an non-anticonnected graph `G`, for
-              the same reason (it is just the complement of the
-              previous graph !).
+            * An anticomponent `C` (or the union of some --but not all-- of
+              them) of an non-anticonnected graph `G`, for the same reason (it
+              is just the complement of the previous graph !).

I would move off on the ear_decomposition changes to a separate ticket as this one is big enough (and likely to have conflicts). However, I would probably consider doing the sorting here.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 8, 2018

Changed commit from 672b173 to 8681351

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 8, 2018

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

4685538trac #26432: reviewer's comments
8681351trac #26432: other corrections

@dcoudert
Copy link
Contributor Author

dcoudert commented Oct 8, 2018

comment:7

Thanks for all the comments. I will modify ear_decomposition in a separate ticket.

I have removed sorting from several example. Was not needed.

Concerning the sorting of output in cliques_maximal and vertex_cover. Should we put a deprecation warning ? if so, a dedicated ticket is certainly better (easier to check), no ?

@tscrim
Copy link
Collaborator

tscrim commented Oct 8, 2018

comment:8

Replying to @dcoudert:

Concerning the sorting of output in cliques_maximal and vertex_cover. Should we put a deprecation warning ? if so, a dedicated ticket is certainly better (easier to check), no ?

I would say it is fine. There is not a decent reason I can think of why someone should be assuming the output is sorted. Nor was it documented that the output was sorted.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 8, 2018

Changed commit from 8681351 to 9a648e7

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 8, 2018

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

5b0c7b4trac #26432: remove sorting in vertex_cover and cliques_maximal
d27d578trac #26432: more care in input blocks
9a648e7trac #26432: further corrections

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 8, 2018

Changed commit from 9a648e7 to 9e5ebb3

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 8, 2018

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

9e5ebb3trac #26432: spaces in lambda declarations

@dcoudert
Copy link
Contributor Author

dcoudert commented Oct 8, 2018

comment:11

Concerning the removal of sorting. It was easier than expected and I have not noticed any impact on other methods.

After that I did additional improvements in INPUT blocks and lambda statements.

Further improvements are certainly possible like moving references to the global file, but I suggest to do that only after the giant patch #26423 is closed.

@tscrim
Copy link
Collaborator

tscrim commented Oct 9, 2018

comment:12

Thanks. LGTM.

@tscrim
Copy link
Collaborator

tscrim commented Oct 9, 2018

Reviewer: Travis Scrimshaw

@dcoudert
Copy link
Contributor Author

dcoudert commented Oct 9, 2018

comment:13

The python3_py test of the patchbot indicates the following issue

+ @@ -2141,34 +2117,40 @@ class Graph(GenericGraph):
+        for u,d in six.iteritems(H.degree(labels=True)):
Python3 incompatible code inserted on 1 non-empty lines

I'm pushing a small change to fix that.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 9, 2018

Changed commit from 9e5ebb3 to 20bf46b

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 9, 2018

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

20bf46btrac #26432: py3 compatibility

@tscrim
Copy link
Collaborator

tscrim commented Oct 9, 2018

comment:15

What was there was correct and works on python3, that is what six does. However, in this case, this makes the code a little easier to understand, although not by much. So I will keep the change.

@dcoudert
Copy link
Contributor Author

dcoudert commented Oct 9, 2018

comment:16

Thank you.

@vbraun
Copy link
Member

vbraun commented Oct 20, 2018

Changed branch from u/dcoudert/26432_clean_graph_py to 20bf46b

@embray
Copy link
Contributor

embray commented Oct 28, 2018

comment:18

This should be re-targeted for 8.5.

@embray embray modified the milestones: sage-8.4, sage-8.5 Oct 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants