setEdgeLineWidth (networkvisualizer)

index

setEdgeLineWidth (networkvisualizer)

Set the line width of edges for a given networkvisualizer object.

Syntax

net = setEdgeLineWidth(net, k)
net = setEdgeLineWidth(net, values)
net = setEdgeLineWidth(net, values, categories)
net = setEdgeLineWidth(net, values, categories, classname)

Arguments

Description

Examples

Setting the node line widths

rng(1, 'twister'); % For reproducibility
% Generate a random network with 50 nodes and 100 edges
nNode = 8;
prepareRandomNetwork = @(n1, n2, numedges) logical(sparse(...
   randi([1 n1], numedges, 1), randi([1 n2], numedges, 1), 1, n1, n2));
W = prepareRandomNetwork(nNode, nNode, 100);
net = networkvisualizer(W);
net.setEdgeColors([0 0 0]);
% Set the edge line width randomly between [0.5 and 2.5]
width_values = 0.5 + 2 * rand(length(net.Edges), 1);
net.setEdgeLineWidth(width_values);
% Plot the network
plot(net);

which produces:

Updating node line widths using classes

size_values = randi([1 2], nNode, 1);
size_cats = {'small', 'big'};
net.addNodeClass(size_cats(size_values), 'NodeSize');
net.setNodeSizes({10, 20}, {'small', 'big'}, 'NodeSize');
% Create an edge class based on 'NodeSize' categories
net.createEdgeClass('EdgeCategory', 'NodeSize')
% Set the color of edges between small nodes to 1 and big nodes to 5
net = setEdgeLineWidth(net, {1, 5}, {'small-small', 'big-big'}, 'EdgeCategory');
plot(net);
%%

which produces:

See Also

networkvisualizer, addNodeClass, addEdgeClass, createEdgeClass, setNodeSizes, setEdgeColors, setEdgeLineStyle