elphick.geomet.utils.layout.digraph_linear_layout

elphick.geomet.utils.layout.digraph_linear_layout(g, orientation='vertical', scale=-1.0)[source]

Position nodes of a digraph in layers of straight lines.

Parameters:
  • g (NetworkX graph or list of nodes) – A position will be assigned to every node in G.

  • orientation (string (default='vertical'))

  • scale (number (default: 1)) – Scale factor for positions.

Returns:

pos – A dictionary of positions keyed by node.

Return type:

dict

Examples

>>> G = nx.complete_multipartite_graph(28, 16, 10)
>>> pos = digraph_linear_layout(g)

Notes

Intended for use with DiGraphs with a single degree 1 node with an out-edge

This algorithm currently only works in two dimensions and does not try to minimize edge crossings.