If nodes are indexes, we can add metadata as a vector, like we’ve done here for the velocity attribute. A node’s value for this attribute will be the value at its id’s index in this array.

showing:

from webweb import Web

web = Web(
    adjacency=[[0, 1], [1, 2]],
    display={
        'nodes' : {
            0 : {
                'age' : 10,
            },
            1 : {
                'age' : 20,
            },
            2 : {
                'age' : 30,
            },
        },
        'metadata' : {
            'velocity' : {
                'values' : [42, 100, 7]
            },
        },
    },
)

# we'll compute node size by the `age` metadata attribute
web.display.sizeBy = 'age'

# we'll compute node color by the `velocity` metadata attribute
web.display.colorBy = 'velocity'

# 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]['age'] = 10
G.nodes[0]['velocity'] = 42
G.nodes[1]['age'] = 20
G.nodes[1]['velocity'] = 100
G.nodes[2]['age'] = 30
G.nodes[2]['velocity'] = 7

web = Web(nx_G=G)

# we'll compute node size by the `age` metadata attribute
web.display.sizeBy = 'age'

# we'll compute node color by the `velocity` metadata attribute
web.display.colorBy = 'velocity'

# 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 two scalar metadata sets
age = [10,20,30];
velocity = [42,100,7];

% Put them in the webweb struct
ww.display.metadata.age.values = age;
ww.display.metadata.velocity.values = velocity;

% BONUS: ask webweb to use age for default node size
%        ask webweb to use velocity for default node color
% These assignments simply need to match the key of the metadata above.
ww.display.sizeBy = 'age';
ww.display.colorBy = 'velocity';

% call webweb
webweb(ww);
{
    "display": {
        "colorBy": "velocity",
        "metadata": {
            "velocity": {
                "values": [
                    42,
                    100,
                    7
                ]
            }
        },
        "nodes": {
            "0": {
                "age": 10
            },
            "1": {
                "age": 20
            },
            "2": {
                "age": 30
            }
        },
        "sizeBy": "age"
    },
    "networks": {
        "webweb": {
            "layers": [
                {
                    "edgeList": [
                        [
                            0,
                            1
                        ],
                        [
                            1,
                            2
                        ]
                    ],
                    "metadata": null,
                    "nodes": {}
                }
            ]
        }
    },
    "title": "webweb"
}