|
| 1 | +## Model |
| 2 | + |
| 3 | +""" |
| 4 | + GLMSBM |
| 5 | +
|
| 6 | +A generative model for graphs with node features, which combines a Generalized Linear Model with a Stochastic Block Model. |
| 7 | +
|
| 8 | +Reference: <https://arxiv.org/abs/2303.09995> |
| 9 | +
|
| 10 | +# Fields |
| 11 | +
|
| 12 | +- `N`: graph size |
| 13 | +- `M`: feature dimension |
| 14 | +- `c`: average degree |
| 15 | +- `λ`: SNR of the communities |
| 16 | +- `ρ`: fraction of nodes revealed |
| 17 | +""" |
| 18 | +struct GLMSBM{R<:Real} <: AbstractSBM |
| 19 | + N::Int |
| 20 | + M::Int |
| 21 | + c::R |
| 22 | + λ::R |
| 23 | + ρ::R |
| 24 | + |
| 25 | + function GLMSBM(; N::Integer, M::Integer, c::R1, λ::R2, ρ::R3) where {R1,R2,R3} |
| 26 | + R = promote_type(R1, R2, R3) |
| 27 | + return new{R}(N, M, c, λ, ρ) |
| 28 | + end |
| 29 | +end |
| 30 | + |
| 31 | +average_degree(glmsbm::GLMSBM) = glmsbm.c |
| 32 | +communities_snr(glmsbm::GLMSBM) = glmsbm.λ |
| 33 | + |
| 34 | +## Latents |
| 35 | + |
| 36 | +""" |
| 37 | + GLMSBMLatents |
| 38 | +
|
| 39 | +The hidden variables generated by sampling from a [`GLMSBM`](@ref). |
| 40 | +
|
| 41 | +# Fields |
| 42 | +
|
| 43 | +- `w::Vector`: feature weights, length `M` |
| 44 | +- `s::Vector`: community assignments, length `N` |
| 45 | +""" |
| 46 | +@kwdef struct GLMSBMLatents{R<:Real} |
| 47 | + w::Vector{R} |
| 48 | + s::Vector{Int} |
| 49 | +end |
| 50 | + |
| 51 | +## Observations |
| 52 | + |
| 53 | +""" |
| 54 | + GLMSBMObservations |
| 55 | +
|
| 56 | +The observations generated by sampling from a [`GLMSBM`](@ref). |
| 57 | +
|
| 58 | +# Fields |
| 59 | +- `A::AbstractMatrix`: symmetric boolean adjacency matrix, size `(N, N)` |
| 60 | +- `g::AbstractGraph`: undirected unweighted graph generated from `A` |
| 61 | +- `F::Matrix`: feature matrix, size `(M, N)` |
| 62 | +- `Ξ::Vector`: revealed communities `±1` for a fraction of nodes and `0` for the rest, length `N` |
| 63 | +""" |
| 64 | +@kwdef struct ContextualSBMObservations{ |
| 65 | + R<:Real,M<:AbstractMatrix{Bool},G<:AbstractGraph{Int} |
| 66 | +} |
| 67 | + A::M |
| 68 | + g::G |
| 69 | + F::Matrix{R} |
| 70 | + Ξ::Vector{Int} |
| 71 | +end |
0 commit comments