In [2]:
from graph_tool.all import *
from pylab import *
import warnings
warnings.filterwarnings('ignore')
In [25]:
g = load_graph("CS-Aarhus_Multiplex_Social.gt.gz")
In [26]:
g
Out[26]:
<Graph object, undirected, with 61 vertices and 620 edges at 0x7f7b70069588>
In [27]:
g.list_properties()
nodeLabel      (vertex)  (type: int32_t)
nodeID         (vertex)  (type: int32_t)
layer          (edge)    (type: int32_t)
In [28]:
ec = g.ep["layer"]
In [29]:
print(ec.a)
[0 0 4 4 4 4 4 4 4 4 4 4 4 0 0 0 0 0 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0 0 1 1 1
 1 1 1 1 2 3 3 4 4 4 4 0 0 0 1 1 1 1 3 3 3 4 4 4 4 4 0 0 0 0 0 2 3 4 4 4 4
 4 4 4 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
 4 4 4 4 0 0 0 0 0 0 0 1 1 1 1 1 2 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 0 0 0 0
 0 0 1 1 1 3 4 0 0 0 0 2 3 4 4 4 4 0 0 0 4 4 4 4 4 4 4 4 4 0 0 0 1 1 2 3 3
 4 4 0 0 0 0 1 1 1 1 1 1 4 4 4 4 4 4 4 0 0 0 1 1 1 3 3 3 4 0 0 0 0 0 0 0 1
 1 1 1 3 3 3 3 4 4 4 0 0 0 0 0 0 2 4 4 4 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 3
 3 3 3 4 4 0 0 0 3 3 3 3 4 4 4 0 0 0 1 1 1 1 4 4 4 4 4 4 4 4 0 0 0 0 0 0 0
 1 1 1 1 1 1 1 1 1 2 2 2 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 0 0 0 0 0 0 0 0
 0 0 0 1 1 1 1 1 3 3 3 3 4 4 4 0 0 0 0 0 0 0 0 0 3 3 3 3 4 4 4 0 0 0 0 1 1
 1 1 1 1 1 1 1 2 2 2 2 2 4 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0 0 0 0 0 4 4 0 0 0
 0 0 0 0 1 1 1 1 1 2 3 3 3 4 0 0 0 0 0 1 1 1 1 3 3 4 0 0 1 1 1 1 1 2 3 4 4
 0 0 0 0 1 1 1 1 1 3 3 3 3 4 4 4 4 4 0 0 0 3 4 0 0 0 1 1 1 3 3 4 0 0 0 1 1
 1 3 3 3 3 4 4 4 0 3 4 4 0 0 1 1 3 3 3 3 4 4 4 4 0 0 2 4 4 4 0 1 1 1 2 3 3
 4 4 0 0 0 3 3 3 4 4 4 0 0 3 3 4 4 0 3 4 0 0 0 4 0 0 0 0 0 0 0 1 1 3 4 4 4
 4 4 4 4 0 0 0 1 1 2 2 3 3 3 3 4 4 4 4 4 0 0 0 1 1 1 3 3 4 4 0 3 4 0 0 2 0
 0 1 3 4 4 0 0 1 1 4 4 4 4 0 0 0 4 0 0 0 4 0 0 3 4 0 1 0]
In [30]:
layer_1 = GraphView(g, efilt=ec.a == 1)
In [31]:
print(layer_1)
<GraphView object, undirected, with 61 vertices and 124 edges, edges filtered by (<PropertyMap object with key type 'Edge' and value type 'bool', for Graph 0x7f7b64f16dd8, at 0x7f7b64f16f60, with values:
[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 1 1 1 1 1 1 1 1 1 1 1 1 1]>, False), vertices filtered by (<PropertyMap object with key type 'Vertex' and value type 'bool', for Graph 0x7f7b64f16dd8, at 0x7f7b64f16940, with values:
[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]>, False) at 0x7f7b64f16dd8>
In [32]:
layer_2 = GraphView(g, efilt=ec.a == 3)
In [33]:
print(layer_2)
<GraphView object, undirected, with 61 vertices and 88 edges, edges filtered by (<PropertyMap object with key type 'Edge' and value type 'bool', for Graph 0x7f7b7007c320, at 0x7f7b64f16cf8, with values:
[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 1 1 1 1 1 1 1 1 1 1 1 1 1 1]>, False), vertices filtered by (<PropertyMap object with key type 'Vertex' and value type 'bool', for Graph 0x7f7b7007c320, at 0x7f7b64f16978, with values:
[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]>, False) at 0x7f7b7007c320>
In [34]:
pos = sfdp_layout(g)
In [35]:
graph_draw(g, pos, edge_color=ec, inline=True)
Out[35]:
<PropertyMap object with key type 'Vertex' and value type 'vector<double>', for Graph 0x7f7b70069588, at 0x7f7b7007c390>
In [36]:
graph_draw(layer_1, pos, inline=True)
Out[36]:
<PropertyMap object with key type 'Vertex' and value type 'vector<double>', for Graph 0x7f7b70069588, at 0x7f7b7007c390>
In [37]:
graph_draw(layer_2, pos, inline=True)