22# #------------------------------------------------------------------------------
33# # tags
44# #------------------------------------------------------------------------------
5-
6- """
7- $SIGNATURES
8-
9- Return the tags for a Node.
10- """
11- getTags (node) = node. tags
12-
135"""
146$SIGNATURES
157
10597
10698function listTags (dfg:: AbstractDFG , sym:: Symbol )
10799 getFnc = isVariable (dfg, sym) ? getVariable : getFactor
108- return getTags (getFnc (dfg, sym))
100+ return refTags (getFnc (dfg, sym))
109101end
110102
111103function mergeTags! (dfg:: InMemoryDFGTypes , sym:: Symbol , tags)
112104 getFnc = isVariable (dfg, sym) ? getVariable : getFactor
113- return union! (getTags (getFnc (dfg, sym)), tags)
105+ return union! (refTags (getFnc (dfg, sym)), tags)
114106end
115107
116108function removeTags! (dfg:: InMemoryDFGTypes , sym:: Symbol , tags)
117109 getFnc = isVariable (dfg, sym) ? getVariable : getFactor
118- return setdiff! (getTags (getFnc (dfg, sym)), tags)
110+ return setdiff! (refTags (getFnc (dfg, sym)), tags)
119111end
120112
121113function emptyTags! (dfg:: InMemoryDFGTypes , sym:: Symbol )
122114 getFnc = isVariable (dfg, sym) ? getVariable : getFactor
123- return empty! (getTags (getFnc (dfg, sym)))
115+ return empty! (refTags (getFnc (dfg, sym)))
124116end
125117
126118# #------------------------------------------------------------------------------
@@ -134,23 +126,5 @@ Determine if the variable or factor neighbors have the `tags:;Vector{Symbol}`, a
134126function hasTags (dfg:: AbstractDFG , sym:: Symbol , tags:: Vector{Symbol} ; matchAll:: Bool = true )
135127 #
136128 alltags = listTags (dfg, sym)
137- return length (filter (x -> x in alltags, tags)) >= (matchAll ? length (tags) : 1 )
138- end
139-
140- """
141- $SIGNATURES
142-
143- Determine if the variable or factor neighbors have the `tags:;Vector{Symbol}`, and `matchAll::Bool`.
144- """
145- function hasTagsNeighbors (
146- dfg:: AbstractDFG ,
147- sym:: Symbol ,
148- tags:: Vector{Symbol} ;
149- matchAll:: Bool = true ,
150- )
151- #
152- # assume only variables or factors are neighbors
153- getNeiFnc = isVariable (dfg, sym) ? getFactor : getVariable
154- alltags = union ((ls (dfg, sym) .| > x -> getTags (getNeiFnc (dfg, x))). .. )
155- return length (filter (x -> x in alltags, tags)) >= (matchAll ? length (tags) : 1 )
129+ return length (alltags ∩ tags) >= (matchAll ? length (tags) : 1 )
156130end
0 commit comments