# Re: [graph-tool] creating and filtering multilayer-networks

```On 02.03.2018 10:33, M. Vigouroux wrote:
> Good morning T.Paula Piexoto and first of all : thank you for the great job
> you’v already done with graph-tool.
>
> I am physicist and I am trying to deal with multilayer large (|E|=10^6)
> graphs. This largeness is basically the reason why i get seduced by
> graph-tool.
>
> I am trying to find a way to *creat* and *filter* graphs G(E,V,D) according
> to the dimension D of sets of nodes and keep edges between them to perform
> common mono-layer graph’s operations with it.
>
> <http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/file/t496105/Network_of_layers_in_multilayer_systems.png>
>
> Multilayered-network with dimension D in (1,2,3,4), each layers C(D) are
> linked with each other with edges. (Reference :
> https://en.wikipedia.org/wiki/Multidimensional_network )
>
> I’m asking myself if you have designed such a thing in graph-tool and if,
> maybe, you have some examples to show how to do that.
>
> I hope I didn’t missed this case in the documentation you have provided…
> ```
```
The way this should be handled with graph-tool is by using a regular graph,
and then annotate the edges using property maps. If all nodes belong to all
layers, then you only need to label each edge with its layer. If the nodes
can belong to a subset of the layers, then you need to annotate the nodes
with property maps as well, i.e.

g = Graph()
elayer = g.new_ep("int")            # layer membership of edges
vlayers = g.new_vp("vector<int>")   # layer membership of nodes

vlayers[5] = [0, 3, 7]  # node 5 belongs to layers 0, 3 and 7
vlayers[8] = [1, 3]     # node 8 belongs to layers 1 and 3

elayer[e] = 3          # edge (5, 8) exists in layer 3

# u3 below is a graph view that isolates the vertices and edges of layer 3

u3 = GraphView(g, efilt=elayer.a == 3, vfilt=lambda v: 3 in vlayers[v])

Best,
Tiago

--
Tiago de Paula Peixoto <ti...@skewed.de>
_______________________________________________
graph-tool mailing list
graph-tool@skewed.de
https://lists.skewed.de/mailman/listinfo/graph-tool
```