(SageMath)
from sage.algebras.lie_algebras.lie_algebra import LieAlgebra
def LieAlgebraFromGraph(G, Module = QQ):
''' Takes a graph and a module (optional) as an input.'''
d = {}
for edge in G.edges(): # this defines the relations among the generators of the Lie algebra
key = ("x" + str(edge[0]), "x" + str(edge[1])) #[x_i, x_j]
value = {"x_" + str(edge[0]) + "_" + str(edge[1]): 1} #x_{i, j}
d[key] = value #appending to the dictionary d
C = LieAlgebras(Module).WithBasis().Graded() #defines the category that we need to work with.
C = C.FiniteDimensional().Stratified().Nilpotent() #specifies that the algebras we want should be finite, stratified, and nilpotent
L = LieAlgebra(Module, d, nilpotent=True, category=C)
def sort_generators_by_grading(lie_algebra, grading_operator): #this sorts the generators by their grading. In this case, V1 are vertices and V2
generators = lie_algebra.gens()
grading = [grading_operator(g) for g in generators] #using the grading operator to split the elements into their respective vector spaces
sorted_generators = [g for _, g in sorted(zip(grading, generators))]
grouped_generators = {}
for g in sorted_generators:
if grading_operator(g) in grouped_generators:
grouped_generators[grading_operator(g)].append(g)
else:
grouped_generators[grading_operator(g)] = [g]
return grouped_generators
grading_operator = lambda g: g.degree() #defining the grading operator
grouped_generators = sort_generators_by_grading(L, grading_operator) #evaluating the function to pull the generators apart
V1 = grouped_generators[1] #elements from vertices
V2 = grouped_generators[2] #elements from edges
return L #, V1, V2 #returns the Lie algebra and the two vector spaces
def betti_numbers(lie_algebra): #this function will calculate the Lie theoretic Betti numbers and return them as a list
dims = []
H = lie_algebra.cohomology()
for n in range(lie_algebra.dimension() + 1):
dims.append(H[n].dimension())
return dims
if n == 1: return [1, 1]
return betti_numbers(LieAlgebraFromGraph(graphs.PathGraph(n)))
for n in range(1, 7): print(
A360571_row(n))