graphistry.layout.sugiyama package


graphistry.layout.sugiyama.sugiyamaLayout module

class graphistry.layout.sugiyama.sugiyamaLayout.SugiyamaLayout(g)

Bases: object

The classic Sugiyama layout aka layered layout.

  • dirvh (int): the current aligment state for alignment policy:

    dirvh=0 -> dirh=+1, dirv=-1: leftmost upper dirvh=1 -> dirh=-1, dirv=-1: rightmost upper dirvh=2 -> dirh=+1, dirv=+1: leftmost lower dirvh=3 -> dirh=-1, dirv=+1: rightmost lower

  • order_iter (int): the default number of layer placement iterations

  • order_attr (str): set attribute name used for layer ordering

  • xspace (int): horizontal space between vertices in a layer

  • yspace (int): vertical space between layers

  • dw (int): default width of a vertex

  • dh (int): default height of a vertex

  • g (GraphBase): the graph component reference

  • layers (list[sugiyama.layer.Layer]): the list of layers

  • layoutVertices (dict): associate vertex (possibly dummy) with their sugiyama attributes

  • ctrls (dict): associate edge with all its vertices (including dummies)

  • dag (bool): the current acyclic state

  • init_done (bool): True if things were initialized


g = nx.generators.connected_watts_strogatz_graph(1000, 2, 0.3)
# render
# positions
positions_dictionary = SugiyamaLayout.arrange(g)

g (GraphBase) –

static arrange(obj, iteration_count=1.5, source_column='source', target_column='target', layout_direction=0, topological_coordinates=False, root=None, include_levels=False)

Returns the positions from a Sugiyama layout iteration.

  • layout_direction

    • 0: top-to-bottom

    • 1: right-to-left

    • 2: bottom-to-top

    • 3: left-to-right

  • obj – can be a Sugiyama graph or a Pandas frame.

  • iteration_count – increase the value for diminished crossings

  • source_column – if a Pandas frame is given, the name of the column with the source of the edges

  • target_column – if a Pandas frame is given, the name of the column with the target of the edges

  • topological_coordinates – whether to use coordinates with the x-values in the [0,1] range and the y-value equal to the layer index.

  • include_levels – whether the tree-level is included together with the coordinates. If so, you get a triple (x,y,level).

  • root – optional list of roots.


a dictionary of positions.


obj (Union[DataFrame, Graph]) –


Creates and defines all dummy vertices for edge e.

ctrls: Dict[graphistry.layout.graph.vertex.Vertex, graphistry.layout.utils.layoutVertex.LayoutVertex]
property dirh
property dirv
property dirvh

Iterator that computes all vertices coordinates and edge routing after just one step (one layer after the other from top to bottom to top). Use it only for “animation” or debugging purpose.

dummyctrl(r, control_vertices)

Creates a DummyVertex at layer r inserted in the ctrl dict of the associated edge and layer.

  • r (int): layer value

  • ctrl (dict): the edge’s control vertices


sugiyama.DummyVertex : the created DummyVertex.

static ensure_root_is_vertex(g, root)

Turns the given list of roots (names or data) to actual vertices in the given graph.

  • g (Graph) – the graph wherein the given roots names are supposed to be

  • root (object) – the data or the vertex


the list of vertices to use as roots

static graph_from_pandas(df, source_column='source', target_column='target')
static has_cycles(obj, source_column='source', target_column='target')

obj (Union[DataFrame, Graph]) –


Initializes the layout algorithm.

  • root (Vertex): a vertex to be used as root

layers: List[graphistry.layout.utils.layer.Layer]
layout(iteration_count=1.5, topological_coordinates=False, layout_direction=0)

Compute every node coordinates after converging to optimal ordering by N rounds, and finally perform the edge routing.


topological_coordinates – whether to use ( [0,1], layer index) coordinates


The map from vertex to LayoutVertex.


Basic edge routing applied only for edges with dummy points. Enhanced edge routing can be performed by using the appropriate


iterator that computes all vertices ordering in their layers (one layer after the other from top to bottom, to top again unless oneway is True).


Computes all vertex coordinates using Brandes & Kopf algorithm. Seeöpf/69cb129a8963b21775d6382d15b0b447b01eb1f8

xspace: int
yspace: int

Module contents