M2 icon indicating copy to clipboard operation
M2 copied to clipboard

trying to enhance graph products

Open fchapoton opened this issue 3 years ago • 23 comments

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

fchapoton avatar Aug 22 '22 19:08 fchapoton

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

fchapoton avatar Aug 23 '22 05:08 fchapoton

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.)

DanGrayson avatar Aug 23 '22 13:08 DanGrayson

This in turn is using

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

fchapoton avatar Aug 23 '22 13:08 fchapoton

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

DanGrayson avatar Aug 23 '22 13:08 DanGrayson

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 ?

fchapoton avatar Sep 29 '22 10:09 fchapoton

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

DanGrayson avatar Oct 01 '22 15:10 DanGrayson

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.

fchapoton avatar Oct 03 '22 12:10 fchapoton

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

DanGrayson avatar Oct 03 '22 15:10 DanGrayson

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 ?

fchapoton avatar Oct 08 '22 07:10 fchapoton

Yes, let's.

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

DanGrayson avatar Oct 08 '22 13:10 DanGrayson

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

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

fchapoton avatar Nov 01 '22 07:11 fchapoton

Maybe we should try emailing them directly.

DanGrayson avatar Nov 12 '22 19:11 DanGrayson

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

DanGrayson avatar Nov 16 '22 19:11 DanGrayson

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

DanGrayson avatar Nov 16 '22 19:11 DanGrayson

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.

DanGrayson avatar Nov 21 '22 19:11 DanGrayson

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 avatar Jan 31 '23 09:01 fchapoton

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 avatar Jan 31 '23 11:01 fchapoton

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

fchapoton avatar Feb 01 '23 16:02 fchapoton

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 avatar Apr 04 '23 09:04 fchapoton

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..

fchapoton avatar Apr 08 '23 16:04 fchapoton

Why do we see no test results?

DanGrayson avatar Dec 29 '23 19:12 DanGrayson

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 avatar Jan 07 '24 08:01 fchapoton

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}

fchapoton avatar Jan 10 '24 13:01 fchapoton