@@ -34,7 +34,6 @@ export getLabelDict, getDescription, setDescription, getInnerGraph, getAddHistor
34
34
export getAddHistory, getDescription, getLabelDict
35
35
export addVariable!, addFactor!
36
36
export ls, lsf, getVariables, getFactors, getVariableIds, getFactorIds
37
- export sortVarNested
38
37
export getVariable, getFactor
39
38
export updateVariable!, updateFactor!
40
39
export deleteVariable!, deleteFactor!
@@ -362,82 +361,6 @@ Checks if the graph is not fully connected, returns true if it is not contiguous
362
361
hasOrphans (dfg:: GraphsDFG ):: Bool = ! isFullyConnected (dfg)
363
362
364
363
365
- """
366
- $(SIGNATURES)
367
- Test if all elements of the string is a number: Ex, "123" is true, "1_2" is false.
368
- """
369
- allnums (str:: S ) where {S <: AbstractString } = occursin (Regex (string ([" [0-9]" for j in 1 : length (str)]. .. )), str)
370
- # occursin(r"_+|,+|-+", node_idx)
371
-
372
- isnestednum (str:: S ; delim= ' _' ) where {S <: AbstractString } = occursin (Regex (" [0-9]+$(delim) [0-9]+" ), str)
373
-
374
- function sortnestedperm (strs:: Vector{<:AbstractString} ; delim= ' _' )
375
- str12 = split .(strs, delim)
376
- sp1 = sortperm (parse .(Int,getindex .(str12,2 )))
377
- sp2 = sortperm (parse .(Int,getindex .(str12,1 )[sp1]))
378
- return sp1[sp2]
379
- end
380
-
381
- function getFirstNumericalOffset (st:: AS ) where AS <: AbstractString
382
- i = 1
383
- while ! allnums (st[i: i]) i+= 1 ; end
384
- return i
385
- end
386
-
387
- """
388
- $SIGNATURES
389
-
390
- Sort a variable list which may have nested structure such as `:x1_2` -- does not sort for alphabetic characters.
391
- """
392
- function sortVarNested (vars:: Vector{Symbol} ):: Vector{Symbol}
393
- # whos nested and first numeric character offset
394
- sv = string .(vars)
395
- offsets = getFirstNumericalOffset .(sv)
396
- masknested = isnestednum .(sv)
397
- masknotnested = true .⊻ masknested
398
-
399
- # strip alphabetic characters from front
400
- msv = sv[masknotnested]
401
- msvO = offsets[masknotnested]
402
- nsv = sv[masknested]
403
- nsvO = offsets[masknested]
404
-
405
- # do nonnested list separately
406
- nnreducelist = map ((s,o) -> s[o: end ], msv, msvO)
407
- nnintlist = parse .(Int, nnreducelist)
408
- nnp = sortperm (nnintlist)
409
- nnNums = nnintlist[nnp] # used in mixing later
410
- nonnested = msv[nnp]
411
- smsv = vars[masknotnested][nnp]
412
-
413
- # do nested list separately
414
- nestedreducelist = map ((s,o) -> s[o: end ], nsv, nsvO)
415
- nestedp = sortnestedperm (nestedreducelist)
416
- nesNums = parse .(Int, getindex .(split .(nestedreducelist[nestedp], ' _' ),1 )) # used in mixing later
417
- nested = nsv[nestedp]
418
- snsv = vars[masknested][nestedp]
419
-
420
- # mix back together, pick next sorted item from either pile
421
- retvars = Vector {Symbol} (undef, length (vars))
422
- nni = 1
423
- nesi = 1
424
- lsmsv = length (smsv)
425
- lsnsv = length (snsv)
426
- MAXMAX = 999999999999
427
- for i in 1 : length (vars)
428
- # inner ifs to ensure bounds and correct sorting at end of each list
429
- if (nni<= lsmsv ? nnNums[nni] : MAXMAX) <= (nesi<= lsnsv ? nesNums[nesi] : MAXMAX)
430
- retvars[i] = smsv[nni]
431
- nni += 1
432
- else
433
- retvars[i] = snsv[nesi]
434
- nesi += 1
435
- end
436
- end
437
- return retvars
438
- end
439
-
440
-
441
364
"""
442
365
$(SIGNATURES)
443
366
Retrieve a list of labels of the immediate neighbors around a given variable or factor.
0 commit comments