M2
M2 copied to clipboard
trying to enhance graph products
so that they allow more general labels, as required by #2262
Well, this seems to (sometimes) trigger a failure in Chordal Graphs.
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.)
This in turn is using
treewidth(ChordalGraph):= G ->
max(for v in G.vertexSet list #children(G,v))
Well, that looks independent of the order of vertices. Hmm.
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 ?
The definition of treewidth at https://en.wikipedia.org/wiki/Chordal_graph makes it clear that the ordering of the vertices is not relevant.
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.
Can we conclude that there's a bug somewhere in one of those packages?
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 ?
Yes, let's.
@jburkar1 , @dcookii , @carolinejansen , @abokeefe ?
ping @jburkar1 , @dcookii , @carolinejansen , @abokeefe
We need your help in understanding a failing doctest, please.
Maybe we should try emailing them directly.
Actually, "treewidth" is in the package "Chordal", whose authors are different.
Okay, I've sent email to the authors of Graphs and of Chordal.
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.
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.
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
in the previous simplified example, the elim trees look really different.
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
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..
Why do we see no test results?
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
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}