you can give webweb more than one network and toggle between those networks with the up and down arrow keys.
showing:
from webweb import Web
# define the node names and a hunger metadata attribute to appear in all networks
web = Web(
display={
'nodes' : {
0 : {
'name' : 'dane',
'hunger' : 4,
},
1 : {
'name' : 'sebastian',
'hunger' : 9,
},
2 : {
'name' : 'manny',
'hunger' : 2,
},
3 : {
'name' : 'brock',
'hunger' : 4,
},
4 : {
'name' : 'ted',
'hunger' : 12.1,
},
5 : {
'name' : 'donnie',
'hunger' : 5,
},
}
},
)
# add a 'snake' network
web.networks.snake(
adjacency=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],
nodes={
0 : {
'isHead' : False,
},
1 : {
'isHead' : False,
},
2 : {
'isHead' : False,
},
3 : {
'isHead' : False,
},
4 : {
'isHead' : False,
},
5 : {
'isHead' : True,
},
},
)
# add a 'starfish' network
web.networks.starfish(
adjacency=[[0, 1], [0, 2], [0, 3], [0, 4], [0, 5]],
nodes={
0 : {
'texture' : 'gooey',
'power' : 1,
},
1 : {
'texture' : 'fishy',
'power' : 3,
},
2 : {
'texture' : 'chewy',
'power' : 3.8,
},
3 : {
'texture' : 'crunchy',
'power' : 0.2,
},
4 : {
'texture' : 'chewy',
'power' : 1,
},
5 : {
'texture' : 'gooey',
'power' : 3.1415,
},
}
)
# display the `starfish` network first
web.display.networkName = 'starfish'
# we'll compute node color by the `texture` attribute
web.display.colorBy = 'texture'
# we'll compute node size by the `hunger` attribute
web.display.sizeBy = 'hunger'
# show the visualization
web.show()
from webweb import Web
import networkx as nx
# define the node names and a hunger metadata attribute to appear in all networks
web = Web(
display={
'nodes' : {
0 : {
'name' : 'dane',
'hunger' : 4,
},
1 : {
'name' : 'sebastian',
'hunger' : 9,
},
2 : {
'name' : 'manny',
'hunger' : 2,
},
3 : {
'name' : 'brock',
'hunger' : 4,
},
4 : {
'name' : 'ted',
'hunger' : 12.1,
},
5 : {
'name' : 'donnie',
'hunger' : 5,
},
}
},
)
snake = nx.Graph()
snake.add_edges_from([[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]])
snake.nodes[0]['isHead'] = False
snake.nodes[1]['isHead'] = False
snake.nodes[2]['isHead'] = False
snake.nodes[3]['isHead'] = False
snake.nodes[4]['isHead'] = False
snake.nodes[5]['isHead'] = True
# add the 'snake' network
web.networks.snake(nx_G=snake)
starfish = nx.Graph()
starfish.add_edges_from([[0, 1], [0, 2], [0, 3], [0, 4], [0, 5]])
starfish.nodes[0]['texture'] = 'gooey'
starfish.nodes[0]['power'] = 1
starfish.nodes[1]['texture'] = 'fishy'
starfish.nodes[0]['power'] = 3
starfish.nodes[2]['texture'] = 'chewy'
starfish.nodes[0]['power'] = 3.8
starfish.nodes[3]['texture'] = 'crunchy'
starfish.nodes[0]['power'] = 0.2
starfish.nodes[4]['texture'] = 'chewy'
starfish.nodes[0]['power'] = 1
starfish.nodes[5]['texture'] = 'gooey'
starfish.nodes[0]['power'] = 3.1415
# add the 'starfish' network
web.networks.starfish(nx_G=starfish)
# display the `starfish` network first
web.display.networkName = 'starfish'
# we'll compute node color by the `hunger` attribute
web.display.colorBy = 'hunger'
# we'll compute node size by the `isHead` attribute
web.display.sizeBy = 'isHead'
# show the visualization
web.show()
% set some node names and a metadata attribute (hunger) to appear for all
% of the networks that we will display. Since these metadata attributes
% apply globally, we put them under ww.display
ww.display.metadata.names = {'dane','sebastian','manny','brock','ted','donnie'};
ww.display.metadata.hunger = [4,9,2,4,12.1,5];
% define a network called snake
ww.networks.snake.edgeList = [1,2; 2,3; 3,4; 4,5; 5,6];
ww.networks.snake.metadata.isHead.values = [0,0,0,0,0,1];
% define another called starfish
ww.networks.starfish.edgeList = [1,2; 1,3; 1,4; 1,5; 1,6];
ww.networks.starfish.metadata.texture.values={'gooey','fishy','chewy',...
'crunchy','chewy','gooey'};
ww.networks.starfish.metadata.power.values={1,3,3.8,0.2,1,3.1415};
% BONUS force the starfish network to display first by default
ww.display.networkName = 'starfish';
% BONUS force node color to texture metadata
ww.display.colorBy = 'texture';
% BONUS force node size to isHead metadata
ww.display.sizeBy = 'hunger';
webweb(ww)
{
"display": {
"colorBy": "texture",
"networkName": "starfish",
"nodes": {
"0": {
"hunger": 4,
"name": "dane"
},
"1": {
"hunger": 9,
"name": "sebastian"
},
"2": {
"hunger": 2,
"name": "manny"
},
"3": {
"hunger": 4,
"name": "brock"
},
"4": {
"hunger": 12.1,
"name": "ted"
},
"5": {
"hunger": 5,
"name": "donnie"
}
},
"sizeBy": "hunger"
},
"networks": {
"snake": {
"layers": [
{
"edgeList": [
[
0,
1
],
[
1,
2
],
[
2,
3
],
[
3,
4
],
[
4,
5
]
],
"metadata": null,
"nodes": {
"0": {
"isHead": false
},
"1": {
"isHead": false
},
"2": {
"isHead": false
},
"3": {
"isHead": false
},
"4": {
"isHead": false
},
"5": {
"isHead": true
}
}
}
]
},
"starfish": {
"layers": [
{
"edgeList": [
[
0,
1
],
[
0,
2
],
[
0,
3
],
[
0,
4
],
[
0,
5
]
],
"metadata": null,
"nodes": {
"0": {
"power": 1,
"texture": "gooey"
},
"1": {
"power": 3,
"texture": "fishy"
},
"2": {
"power": 3.8,
"texture": "chewy"
},
"3": {
"power": 0.2,
"texture": "crunchy"
},
"4": {
"power": 1,
"texture": "chewy"
},
"5": {
"power": 3.1415,
"texture": "gooey"
}
}
}
]
}
},
"title": "webweb"
}