nexxT.services.gui.GraphLayering module

This module implements a graph layering algorithm inspired by https://en.wikipedia.org/wiki/Layered_graph_drawing

class nexxT.services.gui.GraphLayering.GraphRep(baseGraphScene=None)[source]

Bases: object

This class implements the “auto layout” feature for nexxT configuration GUI service.

__init__(baseGraphScene=None)[source]
addEdge(n1, n2)[source]

Adds an edge to the graph

Parameters:
  • n1 – from node (string id)

  • n2 – to node (string id)

Returns:

addNode(n)[source]

Adds a new node to the graph

Parameters:

n – a unique string id

Returns:

None

assignLayers()[source]

Assign nodes to layers

Returns:

layers (a list of a list of nodes), node2layer (a dictionary assigning nodes to layer indices)

dump(title=None)[source]

Dump to stdout for debugging

Parameters:

title – an optional title for the stdout section

Returns:

layersToNodeNames(layers)[source]

convert the layering result back to node names

Parameters:

layers – result from sortLayers (list of list of int)

Returns:

list of list of string

sortLayers()[source]

Sort the layers to avoid too many crossings. Note that this does not take the non-sortable ports into account.

Returns:

layers (a list of a list of nodes), numCrosses (number of crossings in the graph)

topological_sort()[source]

Topological sorting of the graph. Side effect: self.cycleEdges is a set of edges to be ignored for forcing a DAG.

Returns: