with(combinat); pet_cycleind_symm := proc(n) local l; option remember; if n=0 then return 1; fi; expand(1/n*add(a[l]*pet_cycleind_symm(n-l), l=1..n)); end; pet_cycleind_knn := proc(n) option remember; local cindA, cindB, sind, t1, t2, term, res, cmb, len, l1, l2, cycs, uidx, vidx, u, v, inst1; if n=1 then sind := [a[1]]; else sind := pet_cycleind_symm(n); fi; cindA := 0; for t1 in sind do for t2 in sind do res := 1; for u in indets(t1) do l1 := op(1, u); for v in indets(t2) do l2 := op(1, v); len := lcm(l1, l2); res := res * a[len]^(degree(t1, u)*degree(t2, v) *l1*l2/len); od; od; cindA := cindA + lcoeff(t1)*lcoeff(t2)*res; od; od; cindB := 0; for term in sind do res := 1; # edges on different cycles of different sizes for cmb in choose(indets(term), 2) do u := op(1, cmb); v := op(2, cmb); l1 := 2*op(1, u); l2 := 2*op(1, v); res := res * a[lcm(l1, l2)]^((l1*l2/2/lcm(l1, l2))* degree(term, u)*degree(term, v)); od; # edges on different cycles of the same size for u in indets(term) do l1 := 2*op(1, u); inst1 := degree(term, u); # a[l1]^(1/2*inst1*(inst1-1)*l1*l1/2/l1) res := res * a[l1]^(1/2*inst1*(inst1-1)*l1/2); od; # edges on identical cycles of some size for u in indets(term) do l1 := 2*op(1, u); inst1 := degree(term, u); if type(l1/2, even) then # a[l1]^((l1/2)^2/l1); res := res * (a[l1]^(l1/4))^inst1; else # a[l1/2]^(l1/2/(l1/2))*a[l1]^(((l1/2)^2-l1/2)/l1) res := res * (a[l1/2]*a[l1]^(l1/4-1/2))^inst1; fi; od; cindB := cindB + lcoeff(term)*res; od; (cindA+cindB)/2; end; knn_swap_edge_cols := proc(n,k) option remember; local idx_slots, idx_cols, res, term_a, term_b, v_a, v_b, inst_a, inst_b, len_a, len_b, p, q; if n = 1 then idx_slots := [a[1]]; else idx_slots := pet_cycleind_knn(n); fi; if k = 1 then idx_cols := [a[1]]; else idx_cols := pet_cycleind_symm(k); fi; res := 0; for term_a in idx_slots do for term_b in idx_cols do p := 1; for v_a in indets(term_a) do len_a := op(1, v_a); inst_a := degree(term_a, v_a); q := 0; for v_b in indets(term_b) do len_b := op(1, v_b); inst_b := degree(term_b, v_b); if len_a mod len_b = 0 then q := q + len_b*inst_b; fi; od; p := p*q^inst_a; od; res := res + lcoeff(term_a)*lcoeff(term_b)*p; od; od; res; end; A331013 := n -> knn_swap_edge_cols(n, 2); A331014 := n -> knn_swap_edge_cols(n, 3);