createEdgeClass (networkvisualizer)

index

createEdgeClass (networkvisualizer)

Creates a new edge class for a networkvisualizer object.

Syntax

net = createEdgeClass(net, name, nodeclass)
net = createEdgeClass(net, name, categories1, categories2, nodeclass)
net = createEdgeClass(net, name, categories1, categories2, nodeclass1, nodeclass2)

Arguments

Description

Examples

Creating edge categories based on a given node class

rng(1, 'twister'); % For reproducibility
W = [0 1 1 0 0;1 0 0 1 1;1 0 0 0 0;0 0 0 0 1;1 0 1 0 0];
net = networkvisualizer(W);
labels = {'A', 'B', 'C', 'D', 'E'}';
categories = {'M', 'L', 'K', 'M', 'M'}';
net.addNodeClass(categories, 'NodeCategory');
net.setNodeLabels(categories);
net.setNodeFontSize(16);
% Create an edge class based on 'NodeCategory' class
net.createEdgeClass('EdgeCategory', 'NodeCategory');
% Set the edge colors and line widths based on the new edge class
net.setEdgeColors([1 0 0; 0 0.5 1], {'M-M', 'L-M'}, 'EdgeCategory');
net.setEdgeLineWidth({4.5, 2}, {'M-M', 'L-M'}, 'EdgeCategory');
plot(net);

which produces:

Creating edge categories based on different node classes

size_category = {'big', 'big', 'small', 'small', 'medium'};
net.addNodeClass(size_category, 'NodeSize');
% Resize the nodes based on their 'NodeSize' categories
net.setNodeSizes({20 15 10}, {'big', 'medium', 'small'}, 'NodeSize');
% Create an edge class between 'big' nodes
net.createEdgeClass('big-big', 'big', 'big', 'NodeSize');
% Create an edge class between 'small' and category 'L' nodes
net.createEdgeClass('small-L', 'small', 'L', 'NodeSize', 'NodeCategory');
% Set color of 'small-L' edges as purple and 'big-big' edges as dark green
net.setEdgeColors({[1 0 1] [0.5 0.7 0.6]}, {true, true}, {'small-L', 'big-big'});
% Set line width of 'small-L' edges as 5 and 'big-big' edges as 9
net.setEdgeLineWidth({5 9}, {true, true}, {'small-L', 'big-big'});
plot(net);

which produces:

See Also

networkvisualizer, addNodeClass, addEdgeClass, setEdgeLineWidth, setEdgeColors, setEdgeLineStyle