Skip to content

Commit 45f3577

Browse files
committed
fix: swap direction of edges in update_functions_to_interaction_graph
1 parent 6d17ee5 commit 45f3577

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/qualitative_networks.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,10 @@ function update_functions_to_interaction_graph(
239239
graph[entity] = Entity{Int}(fn, domain)
240240
end
241241

242-
for (e1, f) in zip(entities, update_functions)
242+
for (dst, f) in zip(entities, update_functions)
243243
input_entities = collect(Leaves(f))
244-
for e2 in input_entities
245-
add_edge!(graph, e1, e2)
244+
for src in input_entities
245+
add_edge!(graph, src, dst)
246246
end
247247
end
248248

test/qn_test.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,19 @@ end
2222
@test issubset(Set(constants), Set(g.rules))
2323
end
2424

25+
@testitem "QN Graph Correctness" begin
26+
entities = [:a, :b, :c]
27+
target_fns = Union{Expr,Integer,Symbol}[:(-c), :a, :b]
28+
domains = [0:2 for _ = 1:3]
29+
30+
qn = QN(entities, target_fns, domains)
31+
g = get_graph(qn)
32+
33+
@test haskey(g, :c, :a)
34+
@test haskey(g, :a, :b)
35+
@test haskey(g, :b, :c)
36+
end
37+
2538
@testitem "QN Sampling" setup = [RandomSetup, ExampleQN] begin
2639
using Graphs: ne, nv
2740
graph = get_graph(qn)

0 commit comments

Comments
 (0)