Reference
BlockmodelUtils.Blockmodel — TypeStruct representing a graph's blocked adjacency matrix.
Base.map — Methodmap(fun, bm::Blockmodel)Map function fun over the blocks of the Blockmodel bm and return a k by k matrix, where k is the number of groups constituting the blockmodel.
Example
using Graphs, BlockmodelUtils
g = erdos_renyi(20, 0.1)
gs = rand(['a', 'b'], 20)
bm = blockmodel(g, gs)
map(sum, bm) # number of edges in each blockBlockmodelUtils.blockmodel — Methodblockmodel(g, groups; by=identity)Create a Blockmodel from Graphs.AbstractGraph g and vector of group memberships groups. The function passed to by used to order the groups in the blockmodel.
Example
using Graphs, BlockmodelUtils
g = erdos_renyi(20, 0.1)
gs = rand(['a', 'b'], 20)
bm = blockmodel(g, gs)BlockmodelUtils.densityplot — Functiondensityplot!(ax, bm)
densityplot(bm)Plot the block density matrix as a heatmap.
Attributes
xticklabels = bm.labelsyticklabels = bm.labelsrotate_xlabels= falsekwargs...are passed toMakie.heatmap
BlockmodelUtils.densityplot! — Functiondensityplot!(ax, bm)
densityplot(bm)Plot the block density matrix as a heatmap.
Attributes
xticklabels = bm.labelsyticklabels = bm.labelsrotate_xlabels= falsekwargs...are passed toMakie.heatmap
BlockmodelUtils.ei_index — Methodei_index(g, groups; level=:graph, mode=:both)Compute Krackhardt's EI-index (Krackhardt & Stern 1988) for graph g and vector of group affiliations groups, defined as (E - I) / (E + I) for external (between group) edges E and internal (withing group) edges I.
Specify the level at wich to compute the index by setting the respective keyword to graph, group, or node. For directed g, specify the mode as both, in, or out. For level=graph, the three modes will be the same.
Example
using Graphs, BlockmodelUtils
g = erdos_renyi(20, 0.1);
gs = rand('a':'c', 20);
ei_index(g, gs; level=:group)BlockmodelUtils.flowerplot — Functionflowerplot!(ax, bm)
flowerplot(bm)Plot the network with nodes positioned in circles according to the blockmodel groups. The first group is placed in the center.
Attributes
edgecolor = :grey70edgewidth = 1nodecolor = :blackshowlabels = trueradii = fill(1, length(bm.labels))args...further arguments are passed toMakie.scatter
BlockmodelUtils.flowerplot! — Functionflowerplot!(ax, bm)
flowerplot(bm)Plot the network with nodes positioned in circles according to the blockmodel groups. The first group is placed in the center.
Attributes
edgecolor = :grey70edgewidth = 1nodecolor = :blackshowlabels = trueradii = fill(1, length(bm.labels))args...further arguments are passed toMakie.scatter
BlockmodelUtils.permuteplot — Functionpermuteplot!(ax, bm)
permuteplot(bm)Plot the permuted adjacency matrix with a grid outlining the blockmodel blocks.
Attributes
cellcolor = :blacklinecolor = :blackframecolor = linecolorrotate_xlabels = falexticklabels = bm.labelsyticklabels = bm.labels
BlockmodelUtils.permuteplot! — Functionpermuteplot!(ax, bm)
permuteplot(bm)Plot the permuted adjacency matrix with a grid outlining the blockmodel blocks.
Attributes
cellcolor = :blacklinecolor = :blackframecolor = linecolorrotate_xlabels = falexticklabels = bm.labelsyticklabels = bm.labels
Graphs.density — Methoddensity(bm::Blockmodel)Compute the blockdensity matrix for Blockmodel bm. For diagonal blocks, the diagonal is subtracted from the number of possible edges.