Skip to content

Commit

Permalink
Improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeyT1994 committed Nov 6, 2023
1 parent 3ad3cbc commit 6df26bd
Showing 1 changed file with 0 additions and 16 deletions.
16 changes: 0 additions & 16 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,3 @@ function line_to_tree(line::Vector)
end
return [line_to_tree(line[1:(end - 1)]), line[end]]
end

#Custom edge order for updating all BP message tensors on a general undirected graph. On a tree this will yield a sequence which only needs to be performed once.
function BP_edge_update_order(g::NamedGraph; root_vertex=NamedGraphs.default_root_vertex)
@assert !is_directed(g)
forests = NamedGraphs.forest_cover(g)
edges = NamedEdge[]
for forest in forests
trees = NamedGraph[forest[vs] for vs in connected_components(forest)]
for tree in trees
tree_edges = post_order_dfs_edges(tree, root_vertex(tree))
push!(edges, vcat(tree_edges, reverse(reverse.(tree_edges)))...)
end
end

return edges
end

0 comments on commit 6df26bd

Please sign in to comment.