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

trying to enhance graph products #2576

Open
wants to merge 2 commits into
base: development
Choose a base branch
from

Conversation

fchapoton
Copy link
Contributor

@fchapoton fchapoton commented Aug 22, 2022

so that they allow more general labels, as required by #2262

@fchapoton
Copy link
Contributor Author

Well, this seems to (sometimes) trigger a failure in Chordal Graphs.

@DanGrayson
Copy link
Member

The failure is here:

G = cartesianProduct(cycleGraph 3, pathGraph 5)
I = edgeIdeal G
N = chordalNet(toLex I)
assert(treewidth elimTree N == 6)

Could it be that treewidth depends on the order the vertices of a graph are listed in? (We get 10 instead of 6.)

@fchapoton
Copy link
Contributor Author

This in turn is using

treewidth(ChordalGraph):= G -> 
    max(for v in G.vertexSet list #children(G,v))

@DanGrayson
Copy link
Member

Well, that looks independent of the order of vertices. Hmm.

@fchapoton
Copy link
Contributor Author

fchapoton commented Sep 29, 2022

It seems to me that the result could depend on the ordering of the vertices of the graph. So it could be normal that the tree-width is changed. Indeed the doctest just below finds another tree-width.

Maybe one should ask the authors of the package if it is ok to change the doctest ?

@DanGrayson
Copy link
Member

The definition of treewidth at https://en.wikipedia.org/wiki/Chordal_graph makes it clear that the ordering of the vertices is not relevant.

@fchapoton
Copy link
Contributor Author

Hmm. Trying inside sagemathcell (so M2 version 1.18) to change the labels in the example, I got

loadPackage "Graphs";loadPackage "Chordal";
C = graph({{0,22},{22,1},{1,0}},EntryMode=>"edges");
G = cartesianProduct(C, pathGraph 5)
I = edgeIdeal G
N = chordalNet(toLex I)
treewidth elimTree N

and this gives 10.

@DanGrayson
Copy link
Member

Can we conclude that there's a bug somewhere in one of those packages?

@fchapoton
Copy link
Contributor Author

Either there is a bug, or we do not understand something in the math. I do not claim to understand if treewidth depends on the order of vertices or not. Shall we ask the package authors ?

@DanGrayson
Copy link
Member

Yes, let's.

@jburkar1 , @dcookii , @carolinejansen , @abokeefe ?

@fchapoton
Copy link
Contributor Author

ping @jburkar1 , @dcookii , @carolinejansen , @abokeefe

We need your help in understanding a failing doctest, please.

@DanGrayson
Copy link
Member

Maybe we should try emailing them directly.

@DanGrayson
Copy link
Member

Actually, "treewidth" is in the package "Chordal", whose authors are different.

@DanGrayson
Copy link
Member

Okay, I've sent email to the authors of Graphs and of Chordal.

@DanGrayson
Copy link
Member

DanGrayson commented Nov 21, 2022

Frédéric, if we could demonstrate that there is a bug in treewidth outside of this pull request, it would make a good issue and would give the authors something more immediate to focus on.

@fchapoton
Copy link
Contributor Author

Still not clear to me what goes wrong. Here is another tentative

loadPackage "Graphs";loadPackage "Chordal";loadPackage "NautyGraphs";
C1 = graph({{0,22},{22,1},{1,0}},EntryMode=>"edges");
G1 = cartesianProduct(C1, pathGraph 5);
I1 = edgeIdeal G1;
N1 = chordalNet(toLex I1);
treewidth elimTree N1
C2 = graph({{0,2},{2,1},{1,0}},EntryMode=>"edges");
G2 = cartesianProduct(C2, pathGraph 5);
I2 = edgeIdeal G2;
N2 = chordalNet(toLex I2);
treewidth elimTree N2
areIsomorphic(G1, G2)
N3 = chordalNet(toLex I2,"SuggestOrder");
chordalTria N1;
chordalTria N2;
chordalTria N3;
codimCount(N1)
codimCount(N2)
codimCount(N3)

which gives three different results.

@fchapoton
Copy link
Contributor Author

Here is a smaller example, where we can see explicitly that both edge ideals are isomorphic

loadPackage "Graphs";loadPackage "Chordal";loadPackage "NautyGraphs";
C1 = graph({{0,22},{22,1},{1,0}},EntryMode=>"edges");
G1 = cartesianProduct(C1, pathGraph 2);
I1 = edgeIdeal G1
N1 = chordalNet(toLex I1);
treewidth elimTree N1
C2 = graph({{0,2},{2,1},{1,0}},EntryMode=>"edges");
G2 = cartesianProduct(C2, pathGraph 2);
I2 = edgeIdeal G2
N2 = chordalNet(toLex I2);
treewidth elimTree N2

@fchapoton
Copy link
Contributor Author

in the previous simplified example, the elim trees look really different.

@fchapoton
Copy link
Contributor Author

Here is an even more simplified case

loadPackage "Graphs";loadPackage "Chordal";loadPackage "NautyGraphs";
C1 = graph({{0,22},{1,0}},EntryMode=>"edges");
pt = graph({{0,{1}}});
G1 = cartesianProduct(C1, pt);
I1 = edgeIdeal G1
N1 = chordalNet(toLex I1);
treewidth elimTree N1
C2 = graph({{0,2},{1,0}},EntryMode=>"edges");
G2 = cartesianProduct(C2, pt);
I2 = edgeIdeal G2
N2 = chordalNet(toLex I2);
treewidth elimTree N2

@fchapoton
Copy link
Contributor Author

Very strangely, the failure depends on the value of the third vertex in C1 ; it fails for 22 and 12, works for -6, 10 and 11 and fails differently for -1..

@DanGrayson
Copy link
Member

Why do we see no test results?

@fchapoton
Copy link
Contributor Author

fchapoton commented Jan 7, 2024

Do you mean "please show us the results" ?

loadPackage "Graphs";loadPackage "Chordal";loadPackage "NautyGraphs";

testtreewidth := n -> (
    C1 = graph({{0,n},{1,0}},EntryMode=>"edges");
    pt = graph({{0,{1}}});
    G1 = cartesianProduct(C1, pt);
    I1 = edgeIdeal G1;
    N1 = chordalNet(toLex I1);
    treewidth elimTree N1
    )

for i from -24 to 24 list testtreewidth i

giving a periodicity 8 :

        {3, 3,
    4, 4, 3, 4, 3, 2, 3, 3, 
    4, 4, 3, 4, 3, 2, 3, 3,
    4, 4, 3, 4, 3, 2, *, *,
    4, 4, 3, 4, 3, 2, 3, 3, 
    4, 4, 3, 4, 3, 2, 3, 3, 
    4, 4, 3, 4, 3, 2, 3}

where I have erased the special cases 0 and 1 that conflict with other vertices

@fchapoton
Copy link
Contributor Author

fchapoton commented Jan 10, 2024

This strange behaviour depends on the label in the second factor graph:

loadPackage "Graphs";loadPackage "Chordal";loadPackage "NautyGraphs";

testtreewidth := (n, m) -> (
    C1 = graph({{0,n},{1,0}},EntryMode=>"edges");
    pt = graph({{0,{m}}});
    G1 = cartesianProduct(C1, pt);
    I1 = edgeIdeal G1;
    N1 = chordalNet(toLex I1);
    treewidth elimTree N1
    )

for i from -24 to 24 list testtreewidth (i, 1)

for i from -24 to 24 list testtreewidth (i, 2)

giving

{3, 3, 4, 4, 3, 4, 3, 2, 3, 3, 4, 4, 3, 4, 3, 2, 3, 3, 4, 4, 3, 4, 3, 2, 2, 2, 4, 4, 3, 4, 3, 2, 3, 3, 4, 4, 3, 4, 3, 2, 3, 3, 4, 4, 3, 4, 3, 2, 3}

{3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants