Skip to content

Commit 0b3b6cd

Browse files
committed
Return tuple named
1 parent 48f4fa1 commit 0b3b6cd

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

src/DistributedFactorGraphs.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ export exists, addVariable!, addFactor!, getVariable, getFactor, updateVariable!
103103
export getVariables, getVariableIds, getFactors, getFactorIds, ls, lsf
104104
export isFullyConnected, hasOrphans
105105
export getNeighbors, _getDuplicatedEmptyDFG, getSubgraphAroundNode, getSubgraph
106-
# export getIncidenceMatrix, getIncidenceMatrixSparse
107106
export getBiadjacencyMatrix
108107

109108
export toDot, toDotFile

src/LightDFG/services/LightDFG.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,8 @@ end
326326

327327
#TODO This is just way too strange to call a function getIncidenceMatrix that calls adjacency_matrix internally,
328328
# So I'm going with Biadjacency Matrix https://en.wikipedia.org/wiki/Adjacency_matrix#Of_a_bipartite_graph
329-
function getBiadjacencyMatrix(dfg::LightDFG; solvable::Int=0)::Tuple{LightGraphs.SparseMatrixCSC, Vector{Symbol}, Vector{Symbol}}
329+
# TODO biadjacencyMatrix
330+
function getBiadjacencyMatrix(dfg::LightDFG; solvable::Int=0)::NamedTuple{(:B, :varLabels, :facLabels),Tuple{LightGraphs.SparseMatrixCSC,Vector{Symbol}, Vector{Symbol}}}
330331
varLabels = getVariableIds(dfg, solvable=solvable)
331332
factLabels = getFactorIds(dfg, solvable=solvable)
332333
varIndex = [dfg.g.labels[s] for s in varLabels]
@@ -335,7 +336,7 @@ function getBiadjacencyMatrix(dfg::LightDFG; solvable::Int=0)::Tuple{LightGraphs
335336
adj = adjacency_matrix(dfg.g)
336337

337338
adjvf = adj[factIndex, varIndex]
338-
return adjvf, varLabels, factLabels
339+
return (B=adjvf, varLabels=varLabels, facLabels=factLabels)
339340
end
340341

341342
# this would be an incidence matrix

src/entities/AbstractDFGSummary.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
$(TYPEDEF)
33
Structure for a graph summary.
44
"""
5+
# TODO why is this called Abstract...
56
struct AbstractDFGSummary
67
variables::Dict{Symbol, DFGVariableSummary}
78
factors::Dict{Symbol, DFGFactorSummary}

src/services/AbstractDFG.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,8 @@ a tuple: adjmat::SparseMatrixCSC{Int}, var_labels::Vector{Symbol)
760760
fac_labels::Vector{Symbol). Rows are the factors, columns are the variables,
761761
with the corresponding labels in fac_labels,var_labels.
762762
"""
763-
function getBiadjacencyMatrix(dfg::G; solvable::Int=0)::Tuple{SparseMatrixCSC, Vector{Symbol}, Vector{Symbol}} where G <: AbstractDFG
763+
# TODO API name get seems wrong maybe just biadjacencyMatrix
764+
function getBiadjacencyMatrix(dfg::AbstractDFG; solvable::Int=0)::NamedTuple{(:B, :varLabels, :facLabels), Tuple{SparseMatrixCSC, Vector{Symbol}, Vector{Symbol}}}
764765
varLabels = map(v->v.label, getVariables(dfg, solvable=solvable))
765766
factLabels = map(f->f.label, getFactors(dfg, solvable=solvable))
766767

@@ -772,11 +773,10 @@ function getBiadjacencyMatrix(dfg::G; solvable::Int=0)::Tuple{SparseMatrixCSC, V
772773
factVars = getNeighbors(dfg, getFactor(dfg, factLabel), solvable=solvable)
773774
map(vLabel -> adjMat[fIndex,vDict[vLabel]] = 1, factVars)
774775
end
775-
return adjMat, varLabels, factLabels
776+
return (B=adjMat, varLabels=varLabels, facLabels=factLabels)
776777
end
777778

778-
function getAdjacencyMatrixSparse(dfg::G; solvable::Int=0)::Tuple{SparseMatrixCSC, Vector{Symbol}, Vector{Symbol}} where G <: AbstractDFG
779-
@warn "Deprecated function, please use getBiadjacencyMatrix as this will be removed in v0.6.1"
779+
function getAdjacencyMatrixSparse(dfg::AbstractDFG; solvable::Int=0)
780780
return getBiadjacencyMatrix(dfg, solvable)
781781
end
782782
# -------------------------

0 commit comments

Comments
 (0)