From 3d2c19c420347f3b2bb5c3723e0db8665f8cb80b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Mon, 22 Aug 2022 17:44:29 +0200 Subject: [PATCH 1/2] Update Graphs.m2 trying to fix #2262 --- M2/Macaulay2/packages/Graphs.m2 | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/M2/Macaulay2/packages/Graphs.m2 b/M2/Macaulay2/packages/Graphs.m2 index 0336b7919b5..134adab72a6 100644 --- a/M2/Macaulay2/packages/Graphs.m2 +++ b/M2/Macaulay2/packages/Graphs.m2 @@ -1360,17 +1360,17 @@ isWeaklyConnected Digraph := Boolean => D -> isConnected underlyingGraph D cartesianProduct = method() cartesianProduct(Graph, Graph) := Graph => (G, H) -> ( - V := toList(set vertexSet G ** set vertexSet H); + V := vertexSet G ** vertexSet H; E := flatten for u in V list for v in V list - if (u_0 == v_0 and member(set {u_1, v_1}, edges H)) - or (u_1 == v_1 and member(set {u_0, v_0}, edges G)) + if (u_0 === v_0 and member(set {u_1, v_1}, edges H)) + or (u_1 === v_1 and member(set {u_0, v_0}, edges G)) then {u, v} else continue; graph(V, E, EntryMode => "edges") ) -- the 'directProduct' method is defined in 'Polyhedra' directProduct(Graph,Graph) := Graph => (G, H) -> ( - V := toList(set vertexSet G ** set vertexSet H); + V := vertexSet G ** vertexSet H; E := flatten for u in V list for v in V list if member(set {u_0, v_0}, edges G) and member(set {u_1, v_1}, edges H) then {u, v} else continue; @@ -1387,10 +1387,10 @@ disjointUnion List := Graph => L -> ( graphComposition = method() graphComposition (Graph, Graph) := Graph => (G, H) -> ( - V := toList(set vertexSet G ** set vertexSet H); + V := vertexSet G ** vertexSet H; E := flatten for u in V list for v in V list if member(set {u_0, v_0}, edges G) - or (u_0 == v_0 and member(set {u_1, v_1}, edges H)) + or (u_0 === v_0 and member(set {u_1, v_1}, edges H)) then {u, v} else continue; graph(V, E, EntryMode => "edges") ) @@ -1410,8 +1410,8 @@ strongProduct = method() strongProduct (Graph, Graph) := Graph => (G, H) -> ( V := toList \ toList(set vertexSet G ** set vertexSet H); E' := flatten for u in V list for v in V list - if (u_0 == v_0 and member(set {u_1, v_1}, edges H)) - or (u_1 == v_1 and member(set {u_0, v_0}, edges G)) + if (u_0 === v_0 and member(set {u_1, v_1}, edges H)) + or (u_1 === v_1 and member(set {u_0, v_0}, edges G)) then {u, v} else continue; E'' := flatten for u in V list for v in V list if member(set {u_0, v_0}, edges G) and member(set {u_1, v_1}, edges H) @@ -5509,6 +5509,18 @@ TEST /// assert Equation(degreeSequence pathGraph 5, {2, 2, 2, 1, 1}) /// +TEST /// +-check products with arbitrary labels +G = graph{{a,1}}; +H = graph{{b,2}}; +cp = cartesianProduct(G,H); +assert #(vertexSet cp) == 4 +dp = directProduct(G,H); +assert #(vertexSet dp) == 4 +gc = graphComposition(G,H); +assert #(vertexSet gc) == 4 +/// + end; loadPackage(Graphs, Reload => true) From 54a4ed172dbadfa6f331b05db5b5e03015135f8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Mon, 22 Aug 2022 17:50:05 +0200 Subject: [PATCH 2/2] Update Graphs.m2 oops --- M2/Macaulay2/packages/Graphs.m2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/M2/Macaulay2/packages/Graphs.m2 b/M2/Macaulay2/packages/Graphs.m2 index 134adab72a6..3a5b126ceee 100644 --- a/M2/Macaulay2/packages/Graphs.m2 +++ b/M2/Macaulay2/packages/Graphs.m2 @@ -5510,7 +5510,7 @@ assert Equation(degreeSequence pathGraph 5, {2, 2, 2, 1, 1}) /// TEST /// --check products with arbitrary labels +--check products with arbitrary labels G = graph{{a,1}}; H = graph{{b,2}}; cp = cartesianProduct(G,H);