-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathGraphsDFG.jl
More file actions
677 lines (596 loc) · 20.5 KB
/
GraphsDFG.jl
File metadata and controls
677 lines (596 loc) · 20.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
function hasVariable(dfg::GraphsDFG, label::Symbol)
return haskey(dfg.g.variables, label)
end
function hasFactor(dfg::GraphsDFG, label::Symbol)
return haskey(dfg.g.factors, label)
end
function isVariable(
dfg::GraphsDFG{P, V, F},
sym::Symbol,
) where {P <: AbstractDFGParams, V <: AbstractGraphVariable, F <: AbstractGraphFactor}
return haskey(dfg.g.variables, sym)
end
function isFactor(
dfg::GraphsDFG{P, V, F},
sym::Symbol,
) where {P <: AbstractDFGParams, V <: AbstractGraphVariable, F <: AbstractGraphFactor}
return haskey(dfg.g.factors, sym)
end
function addVariable!(
dfg::GraphsDFG{<:AbstractDFGParams, V, <:AbstractGraphFactor},
variable::V,
) where {V <: AbstractGraphVariable}
if haskey(dfg.g.variables, variable.label)
throw(LabelExistsError("Variable", variable.label))
end
FactorGraphs.addVariable!(dfg.g, variable) || return false
# Track insertion
push!(dfg.addHistory, variable.label)
return variable
end
function addVariable!(
dfg::GraphsDFG{<:AbstractDFGParams, VD, <:AbstractGraphFactor},
variable::AbstractGraphVariable,
) where {VD <: AbstractGraphVariable}
return addVariable!(dfg, VD(variable))
end
function addFactor!(
dfg::GraphsDFG{<:AbstractDFGParams, <:AbstractGraphVariable, F},
factor::F,
) where {F <: AbstractGraphFactor}
if haskey(dfg.g.factors, factor.label)
throw(LabelExistsError("Factor", factor.label))
end
# TODO
# @assert FactorGraphs.addFactor!(dfg.g, getVariableOrder(factor), factor)
variableLabels = Symbol[factor._variableOrderSymbols...]
for vlabel in variableLabels
!hasVariable(dfg, vlabel) && throw(LabelNotFoundError("Variable", vlabel))
end
@assert FactorGraphs.addFactor!(dfg.g, variableLabels, factor)
return factor
end
function addFactor!(
dfg::GraphsDFG{<:AbstractDFGParams, <:AbstractGraphVariable, F},
factor::AbstractGraphFactor,
) where {F <: AbstractGraphFactor}
return addFactor!(dfg, F(factor))
end
function getVariable(dfg::GraphsDFG, label::Symbol)
if !haskey(dfg.g.variables, label)
throw(LabelNotFoundError("Variable", label))
end
return dfg.g.variables[label]
end
function getFactor(dfg::GraphsDFG, label::Symbol)
if !haskey(dfg.g.factors, label)
throw(LabelNotFoundError("Factor", label))
end
return dfg.g.factors[label]
end
function mergeVariable!(dfg::GraphsDFG, variable::AbstractGraphVariable)
if !haskey(dfg.g.variables, variable.label)
addVariable!(dfg, variable)
else
dfg.g.variables[variable.label] = variable
end
return 1
end
function DFG.mergeVariables!(dfg::GraphsDFG, variables)
cnts = map(v -> mergeVariable!(dfg, v), variables)
return sum(cnts)
end
function mergeFactor!(dfg::GraphsDFG, factor::AbstractGraphFactor)
if !haskey(dfg.g.factors, factor.label)
addFactor!(dfg, factor)
elseif dfg.g.factors[factor.label]._variableOrderSymbols != factor._variableOrderSymbols
#TODO should we allow merging the factor neighbors or error as before?
error("Cannot update the factor, the neighbors are not the same.")
# We need to delete the factor if we are updating the neighbors
# deleteFactor!(dfg, factor.label)
# addFactor!(dfg, factor)
else
dfg.g.factors[factor.label] = factor
end
return 1
end
function DFG.mergeFactors!(dfg::GraphsDFG, factors)
cnts = map(f -> mergeFactor!(dfg, f), factors)
return sum(cnts)
end
function deleteVariable!(dfg::GraphsDFG, label::Symbol)#::Tuple{AbstractGraphVariable, Vector{<:AbstractGraphFactor}}
if !haskey(dfg.g.variables, label)
throw(LabelNotFoundError("Variable", label))
end
deleteNeighbors = true # reserved, orphaned factors are not supported at this time
if deleteNeighbors
del_facs = map(l -> deleteFactor!(dfg, l), listNeighbors(dfg, label))
end
rem_vertex!(dfg.g, dfg.g.labels[label])
return sum(del_facs) + 1
end
function deleteFactor!(dfg::GraphsDFG, label::Symbol)
if !haskey(dfg.g.factors, label)
throw(LabelNotFoundError("Factor", label))
end
rem_vertex!(dfg.g, dfg.g.labels[label])
return 1
end
# """
# tagsFilter = ⊇([:x1])
# tagsFilter([:x1, :x2])
# true
# tagsFilter = Base.Fix1(in, :x1)
# tagsFilter([:x1, :x2])
# true
# """
function getVariables(
dfg::GraphsDFG,
regex::Union{Nothing, Regex} = nothing;
tags::Vector{Symbol} = Symbol[],
solvable::Union{Nothing, Int} = nothing,
solvableFilter::Union{Nothing, Function} = nothing,
labelFilter::Union{Nothing, Function} = nothing,
tagsFilter::Union{Nothing, Function} = nothing,
typeFilter::Union{Nothing, Function} = nothing,
)
variables = collect(values(dfg.g.variables))
if !isnothing(regex)
# NOTE that contains(regex::Regex) is not supported by the NvaDFG.
Base.depwarn(
"The regex filter argument is deprecated, use kwarg `labelFilter=contains(regex)` instead", #v0.28
:getVariables,
)
filterDFG!(variables, contains(regex), (String ∘ getLabel))
end
if !isempty(tags)
# NOTE that !isdisjoint is not supported by NvaDFG.
Base.depwarn(
"tags kwarg is deprecated, use kwarg `tagsFilter = !isdisjoint(tags)` instead", #v0.28
:getVariables,
)
filterDFG!(variables, x -> !isdisjoint(x, tags), getTags)
end
if !isnothing(solvable)
#TODO review. just one solvableFilter or keep solvable as well.
Base.depwarn(
"solvable kwarg is deprecated, use kwarg `solvableFilter = (>=solvable)` instead", #v0.28
:getVariables,
)
filterDFG!(variables, >=(solvable), getSolvable)
end
filterDFG!(variables, labelFilter, getLabel)
filterDFG!(variables, solvableFilter, getSolvable)
filterDFG!(variables, tagsFilter, getTags)
filterDFG!(variables, typeFilter, getVariableType)
return variables
end
function listVariables(
dfg::GraphsDFG,
regexFilter::Union{Nothing, Regex} = nothing;
tags::Vector{Symbol} = Symbol[],
solvable::Union{Nothing, Int} = nothing,
solvableFilter::Union{Nothing, Function} = nothing,
tagsFilter::Union{Nothing, Function} = nothing,
typeFilter::Union{Nothing, Function} = nothing,
labelFilter::Union{Nothing, Function} = nothing,
)
if !isnothing(solvableFilter) ||
!isnothing(tagsFilter) ||
!isnothing(typeFilter) ||
!isnothing(regexFilter) || #TODO deprecated
!isempty(tags) || #TODO deprecated
!isnothing(solvable) #TODO Maybe deprecated?
return map(
getLabel,
getVariables(
dfg,
regexFilter;
tags,
solvable,
solvableFilter,
tagsFilter,
typeFilter,
labelFilter,
),
)
else
# Is it ok to continue using the internal keys property? collect(keys(dfg.g.variables)) allowcates a lot.
labels = copy(dfg.g.variables.keys)
filterDFG!(labels, labelFilter, string)
return labels
end
end
function getFactors(
dfg::GraphsDFG,
regex::Union{Nothing, Regex} = nothing;
tags::Vector{Symbol} = Symbol[],
solvable::Union{Nothing, Int} = nothing,
solvableFilter::Union{Nothing, Function} = nothing,
tagsFilter::Union{Nothing, Function} = nothing,
typeFilter::Union{Nothing, Function} = nothing,
labelFilter::Union{Nothing, Function} = nothing,
)
factors = collect(values(dfg.g.factors))
if !isnothing(regex)
# NOTE that contains(regex::Regex) is not supported by the NvaDFG.
Base.depwarn(
"The regex filter argument is deprecated, use kwarg `labelFilter=contains(regex)` instead", #v0.28
:getFactors,
)
filterDFG!(factors, contains(regex), getLabel)
end
if !isempty(tags)
# NOTE that !isdisjoint is not supported by NvaDFG.
Base.depwarn(
"tags kwarg is deprecated, use kwarg `tagsFilter = !isdisjoint(tags)` instead", #v0.28
:getFactors,
)
filterDFG!(factors, x -> !isdisjoint(x, tags), getTags)
end
if !isnothing(solvable)
#TODO review. just one solvableFilter or keep solvable as well.
Base.depwarn(
"solvable kwarg is deprecated, use kwarg `solvableFilter = (>=solvable)` instead", #v0.28
:getFactors,
)
filterDFG!(factors, >=(solvable), getSolvable)
end
filterDFG!(factors, labelFilter, getLabel)
filterDFG!(factors, solvableFilter, getSolvable)
filterDFG!(factors, tagsFilter, getTags)
filterDFG!(factors, typeFilter, typeof ∘ getFactorType)
return factors
end
function listFactors(
dfg::GraphsDFG,
regexFilter::Union{Nothing, Regex} = nothing;
tags::Vector{Symbol} = Symbol[],
solvable::Union{Nothing, Int} = nothing,
solvableFilter::Union{Nothing, Function} = nothing,
tagsFilter::Union{Nothing, Function} = nothing,
typeFilter::Union{Nothing, Function} = nothing,
labelFilter::Union{Nothing, Function} = nothing,
)
if !isnothing(solvableFilter) ||
!isnothing(tagsFilter) ||
!isnothing(typeFilter) ||
!isnothing(regexFilter) || #TODO deprecated
!isempty(tags) || #TODO deprecated
!isnothing(solvable) #TODO deprecated
return map(
getLabel,
getFactors(
dfg,
regexFilter;
tags,
solvable,
solvableFilter,
tagsFilter,
typeFilter,
labelFilter,
),
)
else
# Is it ok to continue using the internal keys property? collect(keys(dfg.g.factors)) allowcates a lot.
labels = copy(dfg.g.factors.keys)
filterDFG!(labels, labelFilter, string)
return labels
end
end
function isConnected(dfg::GraphsDFG)
return Graphs.is_connected(dfg.g)
# return length(Graphs.connected_components(dfg.g)) == 1
end
_isSolvable(dfg::GraphsDFG, label::Symbol, ready::Nothing) = true
function _isSolvable(dfg::GraphsDFG, label::Symbol, ready::Int)
haskey(dfg.g.variables, label) && (return dfg.g.variables[label].solvable >= ready)
haskey(dfg.g.factors, label) && (return dfg.g.factors[label].solvable >= ready)
throw(LabelNotFoundError(label))
end
function listNeighbors(
dfg::GraphsDFG,
node::AbstractGraphNode;
solvable::Union{Nothing, Int} = nothing,
)
return listNeighbors(dfg, node.label; solvable)
end
function listNeighbors(
dfg::GraphsDFG,
label::Symbol;
solvable::Union{Nothing, Int} = nothing,
)
if !(hasVariable(dfg, label) || hasFactor(dfg, label))
throw(LabelNotFoundError(label))
end
neighbors_il = FactorGraphs.outneighbors(dfg.g, dfg.g.labels[label])
neighbors_ll = [dfg.g.labels[i] for i in neighbors_il]
# Additional filtering
solvable != 0 && filter!(lbl -> _isSolvable(dfg, lbl, solvable), neighbors_ll)
# Variable sorting (order is important)
if haskey(dfg.g.factors, label)
order = intersect(dfg.g.factors[label]._variableOrderSymbols, neighbors_ll)#map(v->v.dfgNode.label, neighbors))
return order::Vector{Symbol}
end
return neighbors_ll::Vector{Symbol}
end
function listNeighborhood(
dfg::GraphsDFG,
variableFactorLabels::Vector{Symbol},
distance::Int;
solvable::Union{Nothing, Int} = nothing,
)
# find neighbors at distance to add
nbhood = Int[]
for l in variableFactorLabels
union!(nbhood, neighborhood(dfg.g, dfg.g.labels[l], distance))
end
allvarfacs = [dfg.g.labels[id] for id in nbhood]
!isnothing(solvable) &&
filter!(nlbl -> (getSolvable(dfg, nlbl) >= solvable), allvarfacs)
return allvarfacs
end
# TODO copy GraphsDFG to GraphsDFG overwrite
# function copyGraph!(destDFG::GraphsDFG,
# sourceDFG::GraphsDFG,
# variableFactorLabels::Vector{Symbol};
# copyGraphMetadata::Bool=false,
# overwriteDest::Bool=false,
# deepcopyNodes::Bool=false,
# verbose::Bool = true)
# Biadjacency Matrix https://en.wikipedia.org/wiki/Adjacency_matrix#Of_a_bipartite_graph
function getBiadjacencyMatrix(
dfg::GraphsDFG;
solvable::Union{Nothing, Int} = nothing,
varLabels = listVariables(dfg; solvable),
factLabels = listFactors(dfg; solvable),
)
varIndex = [dfg.g.labels[s] for s in varLabels]
factIndex = [dfg.g.labels[s] for s in factLabels]
adj = adjacency_matrix(dfg.g)
adjvf = adj[factIndex, varIndex]
return (B = adjvf, varLabels = varLabels, facLabels = factLabels)
end
"""
$(SIGNATURES)
Gets an empty and unique GraphsDFG derived from an existing DFG.
"""
function _getDuplicatedEmptyDFG(
dfg::GraphsDFG{P, V, F},
) where {P <: AbstractDFGParams, V <: AbstractGraphVariable, F <: AbstractGraphFactor}
newDfg = GraphsDFG{P, V, F}(;
agentLabel = getAgentLabel(dfg),
graphLabel = getGraphLabel(dfg),
solverParams = deepcopy(dfg.solverParams),
)
DFG.setDescription!(newDfg, "(Copy of) $(DFG.getDescription(dfg))")
return newDfg
end
#TODO JT test.
"""
$(SIGNATURES)
A replacement for to_dot that saves only hardcoded factor graph plotting attributes.
"""
function savedot_attributes(io::IO, dfg::GraphsDFG)
write(io, "graph G {\n")
for vl in listVariables(dfg)
write(io, "$vl [color=red, shape=ellipse];\n")
end
for fl in listFactors(dfg)
write(
io,
"$fl [color=blue, shape=box, fontsize=8, fixedsize=false, height=0.1, width=0.1];\n",
)
end
for e in edges(dfg.g)
write(io, "$(dfg.g.labels[src(e)]) -- $(dfg.g.labels[dst(e)])\n")
end
return write(io, "}\n")
end
function toDotFile(dfg::GraphsDFG, fileName::String = "/tmp/dfg.dot")
open(fileName, "w") do fid
return savedot_attributes(fid, dfg)
end
return nothing
end
function toDot(dfg::GraphsDFG)
m = PipeBuffer()
savedot_attributes(m, dfg)
data = take!(m)
close(m)
return String(data)
end
function findShortestPathDijkstra(
dfg::GraphsDFG,
from::Symbol,
to::Symbol;
regexVariables::Union{Nothing, Regex} = nothing,
regexFactors::Union{Nothing, Regex} = nothing,
tagsVariables::Vector{Symbol} = Symbol[],
tagsFactors::Vector{Symbol} = Symbol[],
typeVariables::Union{Nothing, <:AbstractVector} = nothing,
typeFactors::Union{Nothing, <:AbstractVector} = nothing,
solvable::Union{Nothing, Int} = nothing,
initialized::Union{Nothing, Bool} = nothing,
)
#
# helper function to filter on vector of types
function _filterTypeList(thelist::Vector{Symbol}, typeList, listfnc = x -> ls(dfg, x))
thelist_ = Symbol[]
for type_ in typeList
union!(thelist_, listfnc(type_))
end
return intersect(thelist, thelist_)
end
#
duplicate =
!isnothing(regexVariables) ||
!isnothing(regexFactors) ||
!isempty(tagsVariables) ||
!isempty(tagsFactors) ||
!isnothing(typeVariables) ||
!isnothing(typeFactors) ||
!isnothing(initialized) ||
!isnothing(solvable)
#
dfg_ = if duplicate
# use copy if filter is being applied
varList = ls(dfg, regexVariables; tags = tagsVariables, solvable = solvable)
fctList = lsf(dfg, regexFactors; tags = tagsFactors, solvable = solvable)
varList = if typeVariables !== nothing
_filterTypeList(varList, typeVariables)
else
varList
end
fctList = if typeFactors !== nothing
_filterTypeList(fctList, typeFactors, x -> lsf(dfg, x))
else
fctList
end
varList = if initialized !== nothing
initmask = isInitialized.(dfg, varList) .== initialized
varList[initmask]
else
varList
end
DFG.deepcopyGraph(typeof(dfg), dfg, varList, fctList)
else
# no filter can be used directly
dfg
end
if !(hasVariable(dfg_, from) || hasFactor(dfg_, from)) ||
!(hasVariable(dfg_, to) || hasFactor(dfg_, to))
# assume filters excluded either `to` or `from` and hence no shortest path
return Symbol[]
end
# GraphsDFG internally uses Integers
frI = dfg_.g.labels[from]
toI = dfg_.g.labels[to]
# get shortest path from graph provider
path_state = Graphs.dijkstra_shortest_paths(dfg_.g.graph, [frI;])
path = Graphs.enumerate_paths(path_state, toI)
dijkpath = map(x -> dfg_.g.labels[x], path)
# return the list of symbols
return dijkpath
end
export bfs_tree
export dfs_tree
export traverseGraphTopologicalSort
function Graphs.bfs_tree(fg::GraphsDFG, s::Symbol)
return bfs_tree(fg.g, fg.g.labels[s])
end
function Graphs.dfs_tree(fg::GraphsDFG, s::Symbol)
return dfs_tree(fg.g, fg.g.labels[s])
end
"""
$SIGNATURES
Return a topological sort of a factor graph as a vector of vertex labels in topological order.
Starting from s::Symbol
"""
function traverseGraphTopologicalSort(fg::GraphsDFG, s::Symbol, fs_tree = bfs_tree)
tree = fs_tree(fg, s)
list = topological_sort_by_dfs(tree)
symlist = map(s -> fg.g.labels[s], list)
return symlist
end
# FG blob entries
function getGraphBlobentry(fg::GraphsDFG, label::Symbol)
if !haskey(fg.graph.blobEntries, label)
throw(LabelNotFoundError("GraphBlobentry", label))
end
return fg.graph.blobEntries[label]
end
function getGraphBlobentries(fg::GraphsDFG; labelFilter::Union{Nothing, Function} = nothing)
entries = collect(values(fg.graph.blobEntries))
filterDFG!(entries, labelFilter, getLabel)
return entries
end
function listGraphBlobentries(
fg::GraphsDFG;
labelFilter::Union{Nothing, Function} = nothing,
)
labels = collect(keys(fg.graph.blobEntries))
filterDFG!(labels, labelFilter, string)
return labels
end
function listAgentBlobentries(fg::GraphsDFG)
return collect(keys(fg.agent.blobEntries))
end
function addGraphBlobentry!(fg::GraphsDFG, entry::Blobentry)
if haskey(fg.graph.blobEntries, entry.label)
throw(LabelExistsError("Blobentry", entry.label))
end
push!(fg.graph.blobEntries, entry.label => entry)
return entry
end
function addGraphBlobentries!(fg::GraphsDFG, entries::Vector{Blobentry})
return map(entries) do entry
return addGraphBlobentry!(fg, entry)
end
end
function DFG.addAgentBlobentry!(fg::GraphsDFG, entry::Blobentry)
if haskey(fg.agent.blobEntries, entry.label)
throw(LabelExistsError("Blobentry", entry.label))
end
push!(fg.agent.blobEntries, entry.label => entry)
return entry
end
function DFG.addAgentBlobentries!(fg::GraphsDFG, entries::Vector{Blobentry})
return map(entries) do entry
return addAgentBlobentry!(fg, entry)
end
end
function DFG.getAgentBlobentry(fg::GraphsDFG, label::Symbol)
if !haskey(fg.agent.blobEntries, label)
throw(LabelNotFoundError("Blobentry", label))
end
return fg.agent.blobEntries[label]
end
function DFG.getAgentBlobentries(
fg::GraphsDFG;
labelFilter::Union{Nothing, Function} = nothing,
)
entries = collect(values(fg.agent.blobEntries))
filterDFG!(entries, labelFilter, getLabel)
return entries
end
function DFG.mergeGraphBlobentry!(dfg::GraphsDFG, entry::Blobentry)
DFG.refBlobentries(dfg.graph)[getLabel(entry)] = entry
return 1
end
function DFG.mergeAgentBlobentry!(dfg::GraphsDFG, entry::Blobentry)
DFG.refBlobentries(dfg.agent)[getLabel(entry)] = entry
return 1
end
function DFG.mergeGraphBlobentries!(dfg::GraphsDFG, entries::Vector{Blobentry})
cnts = map(entries) do entry
return mergeGraphBlobentry!(dfg, entry)
end
return sum(cnts)
end
function DFG.mergeAgentBlobentries!(dfg::GraphsDFG, entries::Vector{Blobentry})
cnts = map(entries) do entry
return mergeAgentBlobentry!(dfg, entry)
end
return sum(cnts)
end
function DFG.deleteGraphBlobentry!(dfg::GraphsDFG, label::Symbol)
if !haskey(dfg.graph.blobEntries, label)
throw(LabelNotFoundError("Blobentry", label))
end
delete!(dfg.graph.blobEntries, label)
return 1
end
function DFG.deleteAgentBlobentry!(dfg::GraphsDFG, label::Symbol)
if !haskey(dfg.agent.blobEntries, label)
throw(LabelNotFoundError("Blobentry", label))
end
delete!(dfg.agent.blobEntries, label)
return 1
end
function DFG.hasGraphBlobentry(dfg::GraphsDFG, label::Symbol)
return haskey(dfg.graph.blobEntries, label)
end
function DFG.hasAgentBlobentry(dfg::GraphsDFG, label::Symbol)
return haskey(dfg.agent.blobEntries, label)
end