Skip to content

Commit

Permalink
Fix add_edge bug (#469)
Browse files Browse the repository at this point in the history
* check for destination index after source index has been added to graph

* add a test to catch duplicate blox on the same graph
  • Loading branch information
harisorgn authored Oct 22, 2024
1 parent 6c96f97 commit 12566bb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Neurographs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ function add_edge!(g::MetaDiGraph, p::Pair; kwargs...)
src, dest = p

src_idx = find_blox(g, src)
dest_idx = find_blox(g, dest)

if isnothing(src_idx)
add_blox!(g, src)
src_idx = nv(g)
end

dest_idx = find_blox(g, dest)

if isnothing(dest_idx)
add_blox!(g, dest)
dest_idx = nv(g)
Expand Down
2 changes: 2 additions & 0 deletions test/graphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ end
@named n3 = LIFNeuron(; namespace = global_ns)
g = MetaDiGraph()

add_edge!(g, n1 => n1; weight = 1)
@test nv(g) == 1
add_edge!(g, n1 => n2; weight = 1.2)
add_edge!(g, n2 => n2; connection_rule = "psp")
add_edge!(g, n3 => n2)
Expand Down

0 comments on commit 12566bb

Please sign in to comment.