1 | initial version |

First, I cannot reproduce an error in Sage 9.4, but computation of a kernel takes forever.

Second, it's better to avoid calculations in the symbolic ring (as inefficient) whenever possible. In this case, the elements of the kernel can be viewed as elements of the fraction field. Correspondingly, modifying the code into:

```
N = 3 #dimension of hypercube graph
G = graphs.CubeGraph(N).to_directed()
#Assign edge labels as symbolic variables
for u,v,l in G.edges(sort=False):
this_label = 'e' + str(u) + 'e' + str(v)
G.set_edge_label(u, v, this_label)
#relabel vertices to facilitate conversion to matrix
G.relabel()
#Create edge dictionary to facilitate conversion to matrix
edge_dict = {(u,v):k for u,v,k in G.edges()}
F = PolynomialRing(QQ, list(edge_dict.values()) ).fraction_field()
#Construct Laplacian matrix
temp = matrix(F, G.order(), G.order(), edge_dict)
L = temp - diagonal_matrix(sum(temp))
#compute Laplacian kernel
ker = transpose(L).kernel()
```

makes it run in a matter of seconds.

2 | No.2 Revision |

First, I cannot reproduce an error in Sage 9.4, but computation of ~~a ~~the kernel takes forever.

Second, it's better to avoid calculations in the symbolic ring (as inefficient) whenever possible. In this case, the elements of the kernel can be viewed as elements of the fraction field. Correspondingly, modifying the code into:

```
N = 3 #dimension of hypercube graph
G = graphs.CubeGraph(N).to_directed()
#Assign edge labels as symbolic variables
for u,v,l in G.edges(sort=False):
this_label = 'e' + str(u) + 'e' + str(v)
G.set_edge_label(u, v, this_label)
#relabel vertices to facilitate conversion to matrix
G.relabel()
#Create edge dictionary to facilitate conversion to matrix
edge_dict = {(u,v):k for u,v,k in G.edges()}
F = PolynomialRing(QQ, list(edge_dict.values()) ).fraction_field()
#Construct Laplacian matrix
temp = matrix(F, G.order(), G.order(), edge_dict)
L = temp - diagonal_matrix(sum(temp))
#compute Laplacian kernel
ker = transpose(L).kernel()
```

makes it run in a matter of seconds.

3 | No.3 Revision |

First, I cannot reproduce an error in Sage 9.4, but computation of the kernel takes forever.

Second, it's better to avoid calculations in the symbolic ring (as inefficient) whenever possible. In this case, the elements of the kernel can be viewed as rational functions in the label variables and thus as elements of the corresponding fraction field. Correspondingly, modifying the code into:

```
N = 3 #dimension of hypercube graph
G = graphs.CubeGraph(N).to_directed()
#Assign edge labels as symbolic variables
for u,v,l in G.edges(sort=False):
this_label = 'e' + str(u) + 'e' + str(v)
G.set_edge_label(u, v, this_label)
#relabel vertices to facilitate conversion to matrix
G.relabel()
#Create edge dictionary to facilitate conversion to matrix
edge_dict = {(u,v):k for u,v,k in G.edges()}
F = PolynomialRing(QQ, list(edge_dict.values()) ).fraction_field()
#Construct Laplacian matrix
temp = matrix(F, G.order(), G.order(), edge_dict)
L = temp - diagonal_matrix(sum(temp))
#compute Laplacian kernel
ker = transpose(L).kernel()
```

makes it run in a matter of seconds.

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.