-
-
Notifications
You must be signed in to change notification settings - Fork 553
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
is_isomorphic broken with keyword edge_labels=True #27232
Comments
comment:1
Here is the current issue, sorting is broken on the CyclotomicField:
|
comment:2
This code is crap. How can you assume that the elements of your ring could be sorted with respect to some total order? |
comment:3
Replying to @videlec:
Right! :-S I was quite puzzled when saw that this was done!! That step in the The above code came up while looking at two character tables coming from two isomorphic groups. They should be equal up to permutation of columns and rows, but it was returns |
comment:4
This is indeed annoying. Many graphs problem like this one have to be fixed with the switch to Python3 (where comparison might simply throw errors)... |
comment:5
Agreed. Many progresses have been done in the graph module and a lot remains to be done. Help fixing problems / reviewing tickets is more than welcome :P I tried the example with Python 2 and 3 and the answer is Do you have any suggestion on how to compare the 2 lists of edge labels knowing that edge labels can be unhashable ? May be this ticket could be moved to the graph component as it will only touch method |
Commit: |
Branch: public/27232_first_trial |
Changed keywords from cyclotomic, matrix, permutation_of to cyclotomic, matrix, permutation_of, is_isomorphic |
comment:6
I tried many stuff today without success. This is really one of the major issue of the graph module. We can do a simple hack to replace the test
However, this is far from enough as method I'm pushing in a public branch what I tried to do. Feel free to modify/correct/etc. and even suppress if you believe it is not a good approach to fix the problem. It's breaking doctests in PS: The cost to pay for accepting anything as an edge label is really high :( New commits:
|
comment:7
There is indeed a general problem with labels (not only for graphs). Ideally, when one has a structure with labels, one should be able to specify
In the current situation, if 1. applies, you can use sort and if 2. applies you can use Python |
comment:8
Replying to @videlec:
That sounds like a reasonable ideal. It does not sound too idealistic either. |
This comment has been minimized.
This comment has been minimized.
Changed branch from public/27232_first_trial to u/dcoudert/27232_fix_morphisms |
comment:10
I pushed a new branch to fix the issues with It took me some time to understand the method, and in particular why and when sort is needed. I reduced the number of places where sort is used, and used Help needed: I use method Please review, check, double check, do some tests, etc. New commits:
|
Author: David Coudert |
comment:11
Replying to @dcoudert:
Get rid of - for label in filterfalse(edge_labels.__contains__, G.edge_labels()):
+ for label in G.edge_labels():
+ if label in edge_labels:
+ continue Although I might also unroll for _,_,label in G.edge_iterator():
if label in edge_labels:
continue |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:13
done. There is this doctest error:
Can anyone tell if it's something serious or if it is sufficient to replace the expected output or the example. |
comment:14
You should not update the output for this test. Here there is an implicit ordering on the vertices and it is not detecting that they should match (instead it is a rotation of the cycle graph by 2 steps). This might be a case where we should force the isomorphism test to (attempt to) sort the output as we need this labeling to be canonical (as there are generally non-trivial automorphisms as in this example). |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:25
Rebased on last beta. This ticket is certainly the last big py3 issue in the graph module. |
comment:26
What do you think about these minor changes? diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py
index 00e39838fe..71424d5e2b 100644
--- a/src/sage/graphs/generic_graph.py
+++ b/src/sage/graphs/generic_graph.py
@@ -23995,13 +23995,13 @@ def graph_isom_equivalent_non_edge_labeled_graph(g, partition=None, standard_lab
edge_partition = [el[1] for el in edge_partition]
edge_partition = [list(chain(*edge_partition))]
- # An edge between u and v with label l and multiplicity k being encoded
- # as an uv edge with label [l,k], we must not assume that an edge with
- # multiplicity 2 is equivalent to a simple edge !
- # Hence, we still distinguish edges with different multiplicity
- if g_has_multiple_edges:
+ else: # g_has_multiple_edges
+ # An edge between u and v with label l and multiplicity k being encoded
+ # as an uv edge with label [l,k], we must not assume that an edge with
+ # multiplicity 2 is equivalent to a simple edge!
+ # Hence, we still distinguish edges with different multiplicity.
- # Gather the partitions of edges with same multiplicity
+ # Gather the partitions of edges with same multiplicity.
tmp = {}
for el, part in edge_partition:
# The multiplicity of a label is the number of edges from u to v I don't have any other comments. Is everyone else happy with this branch? |
comment:28
I followed your idea and now it's |
comment:29
Great! As I said, I'm happy. Others have looked more carefully at this, so I would like to hear from them before setting this to positive review. |
Changed branch from u/dcoudert/27232_fix_morphisms to u/jhpalmieri/27232_fix_morphisms |
Reviewer: Travis Scrimshaw, Dima Pasechnik, John Palmieri |
Changed reviewer from Travis Scrimshaw, Dima Pasechnik, John Palmieri to Travis Scrimshaw, John Palmieri |
comment:32
Sorry, I'll better let this to others, not enough time before going on vacation. |
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
|
comment:34
A small typo - edge labeled with a list ``[[label1, multiplicity], [label1,
+ edge labeled with a list ``[[label1, multiplicity], [label2, |
comment:35
I did the correction and pushed to a new branch in New commits:
|
Changed branch from u/jhpalmieri/27232_fix_morphisms to public/graphs/27232_fix_morphisms |
comment:36
I'm happy with all these modification. The code is much better now and fix py3 failing doctests. Further improvements are certainly possible, but let's do them in another patch. Thank you all for the help. |
Changed branch from public/graphs/27232_fix_morphisms to |
This code led to finding this bug in the
is_isomorphic
method.Here is a simple working example:
The two matrices are equal up to permutation of rows and columns:
But, not over
CyclotomicField
s:Even with 2 is also does not work:
This error is provoked at the level of graphs:
CC: @videlec @tscrim @stumpc5 @dcoudert @dimpase
Component: graph theory
Keywords: cyclotomic, matrix, permutation_of, is_isomorphic
Author: David Coudert
Branch/Commit:
b2218f2
Reviewer: Travis Scrimshaw, John Palmieri
Issue created by migration from https://trac.sagemath.org/ticket/27232
The text was updated successfully, but these errors were encountered: