webweb supports adding layers to networks (think timeslices). You can more forward through these with the right arrow key and backwards with the left.
showing:
from webweb import Web
web = Web(
title='oroboros',
adjacency=[[0, 1], [1, 2], [2, 3]],
metadata={
'isHead' : {
'values' : [True, False, False, False],
}
}
)
# oroboros begins chompin'
web.networks.oroboros.add_layer(
adjacency=[[0, 1], [1, 2], [2, 3], [3, 0]],
metadata={
'isHead' : {
'values' : [True, False, False, False],
}
}
)
web.networks.oroboros.add_layer(
adjacency=[[0, 1], [1, 2], [2, 0]],
metadata={
'isHead' : {
'values' : [True, False, False],
}
}
)
web.networks.oroboros.add_layer(
adjacency=[[0, 1], [1, 0]],
metadata={
'isHead' : {
'values' : [True, False],
}
}
)
# lame symbol for infinity if you ask me.
web.networks.oroboros.add_layer(
adjacency=[],
metadata={
'isHead' : {
'values' : [True],
}
}
)
# display the first layer first (you could put, say, 1 here and it would display the second)
web.display.networkLayer = 0
# we'll compute node color by the `isHead` attribute
web.display.colorBy = 'isHead'
# we'll compute node size by the `isHead` attribute
web.display.sizeBy = 'isHead'
# show the visualization
web.show()
from webweb import Web
import networkx as nx
snake = nx.Graph()
snake.add_edges_from([[0, 1], [1, 2], [2, 3]])
snake.nodes[0]['isHead'] = True
snake.nodes[1]['isHead'] = False
snake.nodes[2]['isHead'] = False
snake.nodes[3]['isHead'] = False
web = Web(title='oroboros', nx_G=snake)
snake.add_edge(0, 3)
web.networks.oroboros.add_layer(nx_G=snake)
snake.remove_node(3)
snake.add_edge(0, 2)
web.networks.oroboros.add_layer(nx_G=snake)
snake.remove_node(2)
snake.add_edge(0, 1)
web.networks.oroboros.add_layer(nx_G=snake)
snake.remove_node(1)
web.networks.oroboros.add_layer(nx_G=snake)
# display the first layer first (you could put, say, 1 here and it would display the second)
web.display.networkLayer = 0
# we'll compute node color by the `isHead` attribute
web.display.colorBy = 'isHead'
# we'll compute node size by the `isHead` attribute
web.display.sizeBy = 'isHead'
# show the visualization
web.show()
% define a few layers' edge lists for a multilayer network called oroboros
l_one = [1,2; 2,3; 3,4];
l_two = [1,2; 2,3; 3,4; 4,1];
l_three = [1,2; 2,3; 3,1];
l_four = [1,2; 2,1];
l_five = [];
% Place the layers under oroboros in the order that you'd like them.
% Let's initialize an empty array of layers first
ww.networks.oroboros.layers = {};
% Build the first layer as a networkObject
netObj.edgeList = l_one;
% Assign it its *own* metadata, specific to this layer
netObj.metadata.isHead.values = [1,0,0,0];
netObj.metadata.isHead.type = 'binary';
% Append it to the layers
ww.networks.oroboros.layers{end+1} = netObj;
% Repeat for layer 2
netObj.edgeList = l_two;
netObj.metadata.isHead.values = [1,0,0,0];
netObj.metadata.isHead.type = 'binary';
ww.networks.oroboros.layers{end+1} = netObj;
% ... and layer 3.
netObj.edgeList = l_three;
netObj.metadata.isHead.values = [1,0,0];
netObj.metadata.isHead.type = 'binary';
ww.networks.oroboros.layers{end+1} = netObj;
% ... and layer 4.
netObj.edgeList = l_four;
netObj.metadata.isHead.values = [1,0];
netObj.metadata.isHead.type = 'binary';
ww.networks.oroboros.layers{end+1} = netObj;
% ... and layer 5.
netObj.edgeList = l_five;
netObj.metadata.isHead.values = 1;
netObj.metadata.isHead.type = 'binary';
ww.networks.oroboros.layers{end+1} = netObj;
% BONUS: set default node color and size to the `isHead` attribute
ww.display.colorBy = 'isHead';
ww.display.sizeBy = 'isHead';
webweb(ww);
{
"display": {
"colorBy": "isHead",
"networkLayer": 0,
"sizeBy": "isHead"
},
"networks": {
"oroboros": {
"layers": [
{
"edgeList": [
[
0,
1
],
[
1,
2
],
[
2,
3
]
],
"metadata": {
"isHead": {
"values": [
true,
false,
false,
false
]
}
},
"nodes": {}
},
{
"edgeList": [
[
0,
1
],
[
1,
2
],
[
2,
3
],
[
3,
0
]
],
"metadata": {
"isHead": {
"values": [
true,
false,
false,
false
]
}
},
"nodes": {}
},
{
"edgeList": [
[
0,
1
],
[
1,
2
],
[
2,
0
]
],
"metadata": {
"isHead": {
"values": [
true,
false,
false
]
}
},
"nodes": {}
},
{
"edgeList": [
[
0,
1
],
[
1,
0
]
],
"metadata": {
"isHead": {
"values": [
true,
false
]
}
},
"nodes": {}
},
{
"edgeList": [],
"metadata": {
"isHead": {
"values": [
true
]
}
},
"nodes": {}
}
]
}
},
"title": "oroboros"
}