The set data structure could perhaps be changed to a SparseMatrix representation for AdjacencyMatrix?
Also UniqueVectors.jl could be potentially useful here.
|
adj = [Set{Int}() for _ in 1:n_qubits] # adjacency list |
the collect call is going to make a new copy of this set; do we have an estimate on how big these sets become?
|
neighbors = collect(adj[v]) |
|
for i in 1:length(neighbors) |
|
for j in i+1:length(neighbors) |
|
toggle_edge(adj, neighbors[i], neighbors[j]) |
|
end |
Is there a reason for the collect call before iterating over this like so? I am guessing the logic here is that adjacency matrix is supposed to be symmetric? A' = A ? would this be simplified by just using the Iterators.product(neighbors, neighbors) and modifying the toggle_edge(adj, v1, v2) to only delete a single edge from the adjacency list at a time? validation for symmetry can be ensure in the generation step so we don't have to wrangle ourselves by collecting the set and trying to setup a nested for loop
|
function toggle_edge(adj, vertex_1, vertex_2) |
|
if vertex_2 in adj[vertex_1] || vertex_1 in adj[vertex_2] |
|
delete!(adj[vertex_1], vertex_2) |
|
delete!(adj[vertex_2], vertex_1) |
|
else |
|
push!(adj[vertex_1], vertex_2) |
|
push!(adj[vertex_2], vertex_1) |
|
end |
|
end |
also toggle_edge!(...) since it mutates the adjacency list.
we should also get rid of this deepcopy and pop call? I am not fully sure of the logic. Since this is a set, which is unordered, how are we ensuring that the pop! is getting out the correct item? is there an implied / expected size of adj[v]?
|
other_neighbors = deepcopy(adj[v]) |
|
delete!(other_neighbors, avoid) |
|
vb = isempty(other_neighbors) ? avoid : pop!(other_neighbors) |
Has the interface SimpleGraph Graphs.jl ever been explored?
https://juliagraphs.org/Graphs.jl/dev/ecosystem/interface/
Maybe we can reduce the indexing by 1 / indexing by 0 headache with OffsetArrays.jl see
|
py_adj = pylist([pylist(adj[i] .- 1) for i in 1:length(adj)]) # subtract 1 to convert to 0-indexing |
Instead of creating a
pylist(pylist([...] .-1)) we can just use an offset array functionality so we don't have to worry about this
The set data structure could perhaps be changed to a SparseMatrix representation for AdjacencyMatrix?
Also
UniqueVectors.jlcould be potentially useful here.benchq/src/benchq/compilation/graph_sim_mini.jl
Line 38 in d487229
the
collectcall is going to make a new copy of this set; do we have an estimate on how big these sets become?benchq/src/benchq/compilation/graph_sim_mini.jl
Lines 146 to 150 in d487229
Is there a reason for the collect call before iterating over this like so? I am guessing the logic here is that adjacency matrix is supposed to be symmetric?
A' = A? would this be simplified by just using the Iterators.product(neighbors, neighbors) and modifying thetoggle_edge(adj, v1, v2)to only delete a single edge from the adjacency list at a time? validation for symmetry can be ensure in the generation step so we don't have to wrangle ourselves by collecting the set and trying to setup a nested for loopbenchq/src/benchq/compilation/graph_sim_mini.jl
Lines 168 to 176 in d487229
also
toggle_edge!(...)since it mutates the adjacency list.we should also get rid of this deepcopy and pop call? I am not fully sure of the logic. Since this is a set, which is unordered, how are we ensuring that the
pop!is getting out the correct item? is there an implied / expected size ofadj[v]?benchq/src/benchq/compilation/graph_sim_mini.jl
Lines 128 to 130 in d487229
Has the interface SimpleGraph Graphs.jl ever been explored?
https://juliagraphs.org/Graphs.jl/dev/ecosystem/interface/
Maybe we can reduce the indexing by 1 / indexing by 0 headache with
OffsetArrays.jlseebenchq/src/benchq/compilation/graph_sim_mini.jl
Line 249 in d487229
Instead of creating a
pylist(pylist([...] .-1))we can just use an offset array functionality so we don't have to worry about this