LabelBundle
public protocol LabelBundle : MergeableMessage
Represents a set of labels and their corresponding weights for use in the expander label propagation algorithm.
For example, we may have categories {A, B, C}. Vertex 1 is seeded with label A, and vertex 3 is seeded with label C. Because vertex 1 is connected to vertex 2, it will propagate its label A along. Vertex 3 is also connected to vertex 2, and sends its label C along. Vertex 2 thus should have a computed label of (assuming equal weight to edges 1->2 and 3->2) 50% A, and 50% C.
Note: a LabelBundle must encode the sparsity associated with the presence or absence of labels.
See also
ParallelGraph.propagateLabels
-
Initializes where every label has
value
.Declaration
Swift
init(repeating value: Float)
-
Scales the weights of the labels in this LabelBundle by
scalar
.Declaration
Swift
mutating func scale(by scalar: Float)
-
scaled(by:
Default implementation) Returns scaled weights for the labels in
self
byscalar
.Default Implementation
Declaration
Swift
func scaled(by scalar: Float) -> Self
-
Adds
scalar
to every label.Declaration
Swift
mutating func conditionalAdd(_ scalar: Float, where hasValue: Self)
-
Update
self
‘s value for every label not contained inself
and contained inother
.Declaration
Swift
mutating func fillMissingFrom(_ other: Self)
-
Add
rhs
to the value of every label inself
‘s label set.Declaration
Swift
static func += (lhs: inout Self, rhs: Float)
-
Add the weights for all labels in
rhs
to the corresponding labels inlhs
.Declaration
Swift
static func += (lhs: inout Self, rhs: Self)
-
Divides lhs by rhs.
Declaration
Swift
static func / (lhs: Self, rhs: Self) -> Self