webweb

MATLAB code examples

Click links to see the visualization produced.

Example 1 - A single network

% create a 100 node adjacency matrix A
A = floor(1.01*rand(100,100)); A=A+A'; A(A>0) = 1;
% call webweb
webweb(A);

Example 2 - Node names

% create a 100 node adjacency matrix A
A = floor(1.01*rand(100,100)); A=A+A'; A(A>0) = 1;
% make up some names
for i=1:size(A,1)
nodeNames{i} = ['node number ' num2str(i-1)];
end
% call webweb
webweb(A,nodeNames);

Example 3 - Two networks

% create two adjacency matrices
A = floor(1.01*rand(100,100)); A=A+A'; A(A>0) = 1;
B = floor(1.02*rand(100,100)); B=B+B'; B(B>0) = 1;
% put them together in a 3D array
nets(:,:,1) = A;
nets(:,:,2) = B;
% call webweb
webweb(nets);

Example 4 - Two networks + Node names

% recapitulate example 3 A = floor(1.01*rand(100,100)); A=A+A'; A(A>0) = 1;
B = floor(1.02*rand(100,100)); B=B+B'; B(B>0) = 1;
nets(:,:,1) = A;
nets(:,:,2) = B;
% create nodes names as in example 2
for i=1:size(A,1)
nodeNames{i} = ['node number ' num2str(i-1)];
end
% call webweb
webweb(nets,nodeNames);

Example 5 - Name the networks

% recapitulate example 3
A = floor(1.01*rand(100,100)); A=A+A'; A(A>0) = 1;
B = floor(1.02*rand(100,100)); B=B+B'; B(B>0) = 1;
nets(:,:,1) = A;
nets(:,:,2) = B;
% make a cell of network names
netNames{1} = 'robotNetwork';
netNames{2} = 'humanNetwork';
webweb(nets,netNames);

Example 6 - Multiple networks, with node and network names

% recapitulate example 3
A = floor(1.01*rand(100,100)); A=A+A'; A(A>0) = 1;
B = floor(1.02*rand(100,100)); B=B+B'; B(B>0) = 1;
nets(:,:,1) = A;
nets(:,:,2) = B;
% recampitulate example 2
for i=1:size(A,1)
nodeNames{i} = ['node number ' num2str(i-1)];
end
% recapitulate example 5
netNames{1} = 'robotNetwork';
netNames{2} = 'humanNetwork';
% call webweb
webweb(nets,nodeNames,netNames);
% Note: this order also works
% webweb(nets,netNames,nodeNames);

Advanced Example - Customized

% Advanced Usage Example
% Make the display a small square
dis.w = 500;
dis.h = 500;
% Increase the charge and the gravity
dis.c = 100;
dis.g = 0.3;
% Give the file a name
dis.name = 'Advanced';
% Name the nodes
dis.nodeNames = {'dane','sebastian','manny','brock','ted','donnie'};
% Give the nodes some labels called hunger that are scalars
dis.labels.hunger.type = 'scalar';
dis.labels.hunger.values = [4,9,2,4,12.1,5];
% Build a few networks
snake(1,2) = 1;
snake(2,3) = 2;
snake(3,4) = 3;
snake(4,5) = 4;
snake(5,6) = 5;
starfish(1,2) = 1;
starfish(1,3) = 1;
starfish(1,4) = 1;
starfish(1,5) = 1;
starfish(1,6) = 1;
% put them into netObjects
nets.snake.adj = snake;
nets.starfish.adj = starfish;
% Add some labels, binary, categorical, etc...
nets.snake.labels.isHead.type = 'binary';
nets.snake.labels.isHead.values = [0,0,0,0,0,1];
nets.snake.labels.slithering.type = 'categorical';
nets.snake.labels.slithering.values = [1,2,2,3,1,2];
nets.starfish.labels.texture.type = 'categorical';
nets.starfish.labels.texture.values = [1,3,0,2,0,1];
nets.starfish.labels.texture.categories = {'chewy','gooey','crunchy','fishy'};
nets.starfish.labels.power.type = 'scalar';
nets.starfish.labels.power.values = [1,3,3.8,0.2,1,3.1415];
% call webweb
webweb(dis,nets) %or webweb(nets,dis);



Back to webweb main page