networkvisualizer

index

networkvisualizer

Initializes the networkvisualizer object from the given network

Syntax

net = networkvisualizer(W)
net = networkvisualizer(W, k)
net = networkvisualizer(W, sizes)

Arguments

Description

Examples

Setting the node labels

rng(1, 'twister'); % For reproducibility
% Generate a random network with 50 nodes and 100 edges
nNode = 50;
prepareRandomNetwork = @(n1, n2, numedges) logical(sparse(...
   randi([1 n1], numedges, 1), randi([1 n2], numedges, 1), 1, n1, n2));
W = prepareRandomNetwork(nNode, nNode, 100);
% Set the nodeSizes randomly and create the networkvisualizer object
nodeSizes = 4 + exprnd(3, nNode, 1);
net = networkvisualizer(W, nodeSizes);
% Plot the network
plot(net);

which produces:

Updating labels using node classes

% Apply sigmoid function to get a coefficient between 0 and 1 for each node
applySigmoid = @(x, k) 2 ./ (1 + exp(-x/k)) - 1;
% Coeff are normalized scores based on nodeSizes
coeff = applySigmoid(nodeSizes, 5);
% Set a color for each node between black (0) and red (1) based on coeff
nodeColors = color_spacing_continuous(coeff, [0 1], [0 0 0; 1 0 0]);
net = setNodeColors(net, nodeColors);
% Draw the network again
plot(net);

which produces:

See Also

sparse, addNodeClass, addEdgeClass, createEdgeClass, setNodeLabels, setNodeColors, setNodeSizes