Skip to content

Commit 512a837

Browse files
committed
Graph Traversals
1 parent 0049aa8 commit 512a837

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/GraphsDFG/services/GraphsDFG.jl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,3 +455,28 @@ function findShortestPathDijkstra( dfg::GraphsDFG,
455455
return dijkpath
456456
end
457457

458+
export bfs_tree
459+
export dfs_tree
460+
export traverseGraphTopologicalSort
461+
462+
function Graphs.bfs_tree(fg::GraphsDFG, s::Symbol)
463+
return bfs_tree(fg.g, fg.g.labels[s])
464+
end
465+
466+
function Graphs.dfs_tree(fg::GraphsDFG, s::Symbol)
467+
return dfs_tree(fg.g, fg.g.labels[s])
468+
end
469+
470+
"""
471+
$SIGNATURES
472+
473+
Return a topological sort of a factor graph as a vector of vertex labels in topological order.
474+
Starting from s::Symbol
475+
"""
476+
function traverseGraphTopologicalSort(fg::GraphsDFG, s::Symbol, fs_tree=bfs_tree)
477+
tree = fs_tree(fg, s)
478+
list = topological_sort_by_dfs(tree)
479+
symlist = map(s->fg.g.labels[s], list)
480+
return symlist
481+
end
482+

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ if get(ENV, "IIF_TEST", "") == "true"
9090
using IncrementalInference
9191

9292
apis = Vector{AbstractDFG}()
93-
push!(apis, LightDFG(solverParams=SolverParams(), userId="[email protected]"))
93+
push!(apis, GraphsDFG(solverParams=SolverParams(), userId="[email protected]"))
9494
get(ENV, "DO_CGDFG_TESTS", "false") == "true" && push!(apis, Neo4jDFG(solverParams=SolverParams(), userId="[email protected]"))
9595

9696
for api in apis

0 commit comments

Comments
 (0)