Skip to content

Commit 5fad036

Browse files
committed
rename v_vertices and f_vertices to eachvariable and eachfactor
1 parent 333b01b commit 5fad036

6 files changed

Lines changed: 21 additions & 21 deletions

File tree

src/IndexedFactorGraphs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ include("factorgraph.jl")
1919
include("generators.jl")
2020
include("infinite_regular_factorgraph.jl")
2121

22-
export AbstractFactorGraph, FactorGraph, nvariables, nfactors, v_vertices, f_vertices, f_vertex, v_vertex,
22+
export AbstractFactorGraph, FactorGraph, nvariables, nfactors, eachvariable, eachfactor, f_vertex, v_vertex,
2323
pairwise_interaction_graph,
2424
neighbors, edges, src, dst, idx, ne, nv, degree,
2525
edge_indices, inedges, outedges,

src/factorgraph.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,18 @@ IndexedGraphs.nv(g::FactorGraph) = nv(g.g)
8888
IndexedGraphs.ne(g::FactorGraph) = ne(g.g)
8989

9090
"""
91-
v_vertices(g::FactorGraph)
91+
eachvariable(g::FactorGraph)
9292
9393
Return a lazy iterator to the indices of variable vertices in `g`.
9494
"""
95-
v_vertices(g::FactorGraph) = 1:nvariables(g)
95+
eachvariable(g::FactorGraph) = 1:nvariables(g)
9696

9797
"""
98-
f_vertices(g::FactorGraph)
98+
eachfactor(g::FactorGraph)
9999
100100
Return a lazy iterator to the indices of factor vertices in `g`.
101101
"""
102-
f_vertices(g::FactorGraph) = 1:nfactors(g)
102+
eachfactor(g::FactorGraph) = 1:nfactors(g)
103103

104104
"""
105105
IndexedGraphs.neighbors(g::FactorGraph, v::FactorGraphVertex)

src/infinite_regular_factorgraph.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ nvariables(::InfiniteRegularFactorGraph) = 1
2727
nfactors(::InfiniteRegularFactorGraph) = 1
2828
Graphs.ne(::InfiniteRegularFactorGraph) = 1
2929
Graphs.edges(::InfiniteRegularFactorGraph) = (IndexedEdge(1,1,1) for _ in 1:1)
30-
v_vertices(::InfiniteRegularFactorGraph) = 1:1
31-
f_vertices(::InfiniteRegularFactorGraph) = 1:1
30+
eachvariable(::InfiniteRegularFactorGraph) = 1:1
31+
eachfactor(::InfiniteRegularFactorGraph) = 1:1
3232

3333
IndexedGraphs.degree(g::InfiniteRegularFactorGraph, v::FactorGraphVertex) = length(neighbors(g, v))
3434

test/factorgraph.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ g = FactorGraph(A)
77
@testset "Basics" begin
88
@test @inferred nfactors(g) == m
99
@test @inferred nvariables(g) == n
10-
@test all(@inferred degree(g, f_vertex(a)) == length(@inferred neighbors(g,f_vertex(a))) for a in f_vertices(g))
11-
@test all(@inferred degree(g, v_vertex(i)) == length(@inferred neighbors(g,v_vertex(i))) for i in v_vertices(g))
10+
@test all(@inferred degree(g, f_vertex(a)) == length(@inferred neighbors(g,f_vertex(a))) for a in eachfactor(g))
11+
@test all(@inferred degree(g, v_vertex(i)) == length(@inferred neighbors(g,v_vertex(i))) for i in eachvariable(g))
1212

1313
@test length(collect(@inferred edges(g))) == @inferred ne(g)
1414

15-
@test all(all(src(e)==a for (e,a) in zip(inedges(g, v_vertex(i)), neighbors(g, v_vertex(i)))) for i in v_vertices(g))
16-
@test all(all(src(e)==i for (e,i) in zip(inedges(g, f_vertex(a)), neighbors(g, f_vertex(a)))) for a in f_vertices(g))
17-
@test all(all(dst(e)==a for (e,a) in zip(outedges(g, v_vertex(i)), neighbors(g, v_vertex(i)))) for i in v_vertices(g))
18-
@test all(all(dst(e)==i for (e,i) in zip(outedges(g, f_vertex(a)), neighbors(g, f_vertex(a)))) for a in f_vertices(g))
15+
@test all(all(src(e)==a for (e,a) in zip(inedges(g, v_vertex(i)), neighbors(g, v_vertex(i)))) for i in eachvariable(g))
16+
@test all(all(src(e)==i for (e,i) in zip(inedges(g, f_vertex(a)), neighbors(g, f_vertex(a)))) for a in eachfactor(g))
17+
@test all(all(dst(e)==a for (e,a) in zip(outedges(g, v_vertex(i)), neighbors(g, v_vertex(i)))) for i in eachvariable(g))
18+
@test all(all(dst(e)==i for (e,i) in zip(outedges(g, f_vertex(a)), neighbors(g, f_vertex(a)))) for a in eachfactor(g))
1919

2020
@test_throws ArgumentError degree(g, 1)
2121
@test_throws ArgumentError neighbors(g, 1)
@@ -51,10 +51,10 @@ end
5151
end
5252

5353
@testset "Edge indices" begin
54-
@test all(v_vertices(g)) do i
54+
@test all(eachvariable(g)) do i
5555
idx.(collect(inedges(g, v_vertex(i)))) == edge_indices(g, v_vertex(i))
5656
end
57-
@test all(f_vertices(g)) do a
57+
@test all(eachfactor(g)) do a
5858
idx.(collect(inedges(g, f_vertex(a)))) == edge_indices(g, f_vertex(a))
5959
end
6060
end

test/infinite_regular_factorgraph.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ g = InfiniteRegularFactorGraph(kᵢ, kₐ)
88
@test nfactors(g) == 1
99
@test nvariables(g) == 1
1010
@test ne(g) == 1
11-
@test v_vertices(g) == 1:1
12-
@test f_vertices(g) == 1:1
11+
@test eachvariable(g) == 1:1
12+
@test eachfactor(g) == 1:1
1313
@test all(edges(g)) do (i, j, id)
1414
i == 1 && j == 1 && id == 1
1515
end
@@ -20,10 +20,10 @@ end
2020
end
2121

2222
@testset "Edge indices" begin
23-
@test all(v_vertices(g)) do i
23+
@test all(eachvariable(g)) do i
2424
idx.(collect(inedges(g, v_vertex(i)))) == edge_indices(g, v_vertex(i))
2525
end
26-
@test all(f_vertices(g)) do a
26+
@test all(eachfactor(g)) do a
2727
idx.(collect(outedges(g, f_vertex(a)))) == edge_indices(g, f_vertex(a))
2828
end
2929
end

test/runtests.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ Check type inference for functions that are likely to be called in hot loops
1717
"""
1818
function test_type_inference(g::AbstractFactorGraph)
1919
all_edges = @inferred edge_indices(g)
20-
i = rand(rng, @inferred v_vertices(g))
21-
a = rand(rng, @inferred f_vertices(g))
20+
i = rand(rng, @inferred eachvariable(g))
21+
a = rand(rng, @inferred eachfactor(g))
2222
di = @inferred degree(g, @inferred v_vertex(i))
2323
da = @inferred degree(g, @inferred f_vertex(a))
2424
∂i = @inferred neighbors(g, v_vertex(i))

0 commit comments

Comments
 (0)