layers(dag, first_layer, /, index_output=False)#

Return a list of layers

A layer is a subgraph whose nodes are disjoint, i.e., a layer has depth 1. The layers are constructed using a greedy algorithm.

  • graph (PyDiGraph) – The DAG to get the layers from

  • first_layer (list) – A list of node ids for the first layer. This will be the first layer in the output

  • index_output (bool) – When set to to True the output layers will be a list of integer node indices.


A list of layers, each layer is a list of node data, or if index_output is True each layer is a list of node indices.

Return type:



InvalidNode – If a node index in first_layer is not in the graph