we can add node names by setting the nodes
attribute in the display
variable
a node in the adjacency list (e.g., 0
here) will have the metadata of the entry under the same key in the nodes
dictionary (if one exists)
showing:
from webweb import Web
web = Web(
adjacency=[[0, 1], [1, 2]],
display={
'nodes' : {
0 : {
'name' : 'Huberg',
},
1 : {
'name' : 'Pierot',
},
2 : {
'name' : 'Slartibertfast',
},
},
},
)
# show the visualization
web.show()
from webweb import Web
import networkx as nx
G = nx.Graph()
G.add_edges_from([[0, 1], [1, 2]])
G.nodes[0]['name'] = 'Huberg'
G.nodes[1]['name'] = 'Pierot'
G.nodes[2]['name'] = 'Slartibertfast'
# create the web
web = Web(nx_G=G)
# show the visualization
web.show()
% define a couple edges
edges = [...
1,2;
2,3;...
];
% Place the edges in a webweb struct called ww
ww.networks.network.edgeList = edges;
% Define some names in an array of cells containing strings
names = {'Huberg','Pierot','Slartibertfast'};
% Put the names in metadata with the special key "names"
ww.display.metadata.name.values = names;
% Call webweb
webweb(ww)
{
"display": {
"nodes": {
"0": {
"name": "Huberg"
},
"1": {
"name": "Pierot"
},
"2": {
"name": "Slartibertfast"
}
}
},
"networks": {
"webweb": {
"layers": [
{
"edgeList": [
[
0,
1
],
[
1,
2
]
],
"metadata": null,
"nodes": {}
}
]
}
},
"title": "webweb"
}