# Graph_embed function

Whenever I use the graph embed function (passing in any symmetric adjacency matrix A and mean photon count of length(A)) the squeezing strength values I am returned are always given back in ascending order.

Furthermore, if a change the order of the rows (and the columns respectively) of the adjacency matrix, I get back the exact same vector of r-values (still in ascending order).

I am confused why this is happening and if this is a feature that I am misunderstanding.

Code:
graph_embed(A, length(A)/2)

I am using Strawberryfields 0.23.0 and Python 3.12

Hi @sar49 , welcome to the Forum!

It would help a lot if you could add your full code including all data and imports. Also include the outputs that you get.

Eg:
I run

``````# Imports
# Data
# Functions
``````

And I get
`result`
However I expected to get
`different_result`

This way I can try to replicate your issue and investigate!

``````from strawberryfields.apps import sample
from strawberryfields.decompositions import graph_embed
import numpy as np
from scipy.io import savemat
#SAMPLING

g = [[0,1,0,0,0,0,0,0],
[1,0,1,0,0,0,0,1],
[0,1,0,1,1,0,0,1],
[0,0,1,0,1,0,0,1],
[0,0,1,1,0,1,0,0],
[0,0,0,0,1,0,1,0],
[0,0,0,0,0,1,0,1],
[0,1,1,1,0,0,1,0]]

A = np.array(g)

#mean photon number
n_mean = 8
photons_per_mode = 1
n_samples = 1
the_samples = sample.sample(A, n_mean, n_samples)

#DECOMPOSITION
(r, U) = graph_embed(A, photons_per_mode)
``````

Hi @sar49 ,

graph_embed uses the takagi decomposition. You can see the source code for it here. There you can see that if the matrix N is real, it uses its eigendecomposition,
`l, U = np.linalg.eigh(N)` .

Since changing the order of the rows doesn’t change the eigen decomposition that’s why you’re getting the same answer.

I hope this clarifies things!

1 Like