if the adjacency matrix we pass has multiple edges between two nodes, the weight of the edge webweb creates between those two nodes will be the sum of those edges’ weights. However, webweb won’t do this with symmetric matrices.
showing:
from webweb import Web
adjacency_matrix = [
[0, .1, 0, 0, 0],
[.1, 0, .5, 0, 0],
[0, .5, 0, 1, 0],
[0, 0, 1, 0, 2],
[0, 0, 0, 2, 0],
]
# create the web
web = Web(adjacency_matrix)
# we'll scale edge widths by weight to create a visual difference
web.display.scaleLinkWidth = True
# show the visualization
web.show()
% define a weighted adjacency matrix
adjacency_matrix = [...
0, .1, 0, 0, 0;...
.1, 0, .5, 0, 0;...
0, .5, 0, 1, 0;...
0, 0, 1, 0, 2;...
0, 0, 0, 2, 0;...
];
% call webweb
webweb(adjacency_matrix);
%% [OPTIONAL] Set default: show weighted edges.
% To set a default parameter, we need to creat a webweb struct
% and place our parameter setting in it.
%
% Convert from the matrix to an edgeList.
[from,to,weight] = find(triu(adjacency_matrix));
% Place this edgeList into a network within the webweb struct
ww.networks.network.edgeList = [from,to,weight];
% Set scaleLinkWidth to True.
ww.display.scaleLinkWidth = 'True';
% call webweb
webweb(ww);
{
"display": {
"scaleLinkWidth": true
},
"networks": {
"webweb": {
"layers": [
{
"edgeList": [
[
1,
0,
0.1
],
[
2,
1,
0.5
],
[
3,
2,
1
],
[
4,
3,
2
]
],
"metadata": null,
"nodes": {}
}
]
}
},
"title": "webweb"
}