From a3db9c01999d45febd41684cf96a64e8f9809b1e Mon Sep 17 00:00:00 2001 From: Joseph Tindall Date: Tue, 21 Nov 2023 11:26:08 -0500 Subject: [PATCH] Trait fns now come in pairs --- .../beliefpropagation_schedule.jl | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/beliefpropagation/beliefpropagation_schedule.jl b/src/beliefpropagation/beliefpropagation_schedule.jl index 7cda8325..cbc5f206 100644 --- a/src/beliefpropagation/beliefpropagation_schedule.jl +++ b/src/beliefpropagation/beliefpropagation_schedule.jl @@ -1,29 +1,26 @@ default_edge_sequence_alg() = "forest_cover" -@traitfn undirected_default_bp_niters(g::AbstractGraph::(!IsDirected)) = - is_tree(g) ? 1 : nothing -function default_bp_niters(g::AbstractGraph) - return undirected_default_bp_niters(undirected_graph(underlying_graph(g))) +@traitfn default_bp_niters(g::::(!IsDirected)) = is_tree(g) ? 1 : nothing +@traitfn function default_bp_niters(g::::IsDirected) + return default_bp_niters(undirected_graph(underlying_graph(g))) end @traitfn function edge_sequence( - g::NamedGraph::(!IsDirected); alg=default_edge_sequence_alg(), kwargs... + g::::(!IsDirected); alg=default_edge_sequence_alg(), kwargs... ) return edge_sequence(Algorithm(alg), g; kwargs...) end -function edge_sequence(g::AbstractGraph; alg=default_edge_sequence_alg(), kwargs...) +@traitfn function edge_sequence(g::::IsDirected; alg=default_edge_sequence_alg(), kwargs...) return edge_sequence(Algorithm(alg), undirected_graph(underlying_graph(g)); kwargs...) end -function edge_sequence(alg::Algorithm, g::AbstractGraph; kwargs...) +@traitfn function edge_sequence(alg::Algorithm, g::::IsDirected; kwargs...) return edge_sequence(alg, undirected_graph(underlying_graph(g)); kwargs...) end @traitfn function edge_sequence( - ::Algorithm"forest_cover", - g::NamedGraph::(!IsDirected); - root_vertex=NamedGraphs.default_root_vertex, + ::Algorithm"forest_cover", g::::(!IsDirected); root_vertex=NamedGraphs.default_root_vertex ) forests = NamedGraphs.forest_cover(g) edges = edgetype(g)[] @@ -38,6 +35,6 @@ end return edges end -@traitfn function edge_sequence(::Algorithm"parallel", g::NamedGraph::(!IsDirected)) +@traitfn function edge_sequence(::Algorithm"parallel", g::::(!IsDirected)) return [[e] for e in vcat(edges(g), reverse.(edges(g)))] end