Layout-related code in the igraph library.
This package contains the implementation of the Layout object.
Layout
Represents the layout of a graph.
_3d_version_for
Creates an alias for the 3D version of the given layout algoritm.
_layout
Returns the layout of the graph according to a layout algorithm.
_layout_auto
Chooses and runs a suitable layout function based on simple topological properties of the graph.
_layout_method_wrapper
Wraps an existing layout method to ensure that it returns a Layout instead of a list of lists.
_layout_sugiyama
Places the vertices using a layered Sugiyama layout.
_layout_mapping
Undocumented
Creates an alias for the 3D version of the given layout algoritm.
This function is a decorator that creates a method which calls func after attaching dim=3 to the list of keyword arguments.
Returns the layout of the graph according to a layout algorithm.
Parameters and keyword arguments not specified here are passed to the layout algorithm directly. See the documentation of the layout algorithms for the explanation of these parameters.
Registered layout names understood by this method are:
- auto, automatic: automatic layout (see
Graph.layout_auto) - bipartite: bipartite layout (see
GraphBase.layout_bipartite) - circle, circular: circular layout (see
GraphBase.layout_circle) - dh, davidson_harel: Davidson-Harel layout (see
GraphBase.layout_davidson_harel) - drl: DrL layout for large graphs (see
GraphBase.layout_drl) - drl_3d: 3D DrL layout for large graphs (see
GraphBase.layout_drl) - fr, fruchterman_reingold: Fruchterman-Reingold layout (see
GraphBase.layout_fruchterman_reingold). - fr_3d, fr3d, fruchterman_reingold_3d: 3D Fruchterman- Reingold layout (see
GraphBase.layout_fruchterman_reingold). - grid: regular grid layout in 2D (see
GraphBase.layout_grid) - grid_3d: regular grid layout in 3D (see
GraphBase.layout_grid) - graphopt: the graphopt algorithm (see
GraphBase.layout_graphopt) - kk, kamada_kawai: Kamada-Kawai layout (see
GraphBase.layout_kamada_kawai) - kk_3d, kk3d, kamada_kawai_3d: 3D Kamada-Kawai layout (see
GraphBase.layout_kamada_kawai) - lgl, large, large_graph: Large Graph Layout (see
GraphBase.layout_lgl) - mds: multidimensional scaling layout (see
GraphBase.layout_mds) - random: random layout (see
GraphBase.layout_random) - random_3d: random 3D layout (see
GraphBase.layout_random) - rt, tree, reingold_tilford: Reingold-Tilford tree layout (see
GraphBase.layout_reingold_tilford) - rt_circular, reingold_tilford_circular: circular Reingold-Tilford tree layout (see
GraphBase.layout_reingold_tilford_circular) - sphere, spherical, circle_3d, circular_3d: spherical layout (see
GraphBase.layout_circle) - star: star layout (see
GraphBase.layout_star) - sugiyama: Sugiyama layout (see
Graph.layout_sugiyama)
Layout object or a list of lists containing the coordinates. If None, uses the value of the plotting.layout configuration key.Layout object.Chooses and runs a suitable layout function based on simple topological properties of the graph.
This function tries to choose an appropriate layout function for the graph using the following rules:
- If the graph has an attribute called layout, it will be used. It may either be a
Layoutinstance, a list of coordinate pairs, the name of a layout function, or a callable function which generates the layout when called with the graph as a parameter. - Otherwise, if the graph has vertex attributes called x and y, these will be used as coordinates in the layout. When a 3D layout is requested (by setting dim to 3), a vertex attribute named z will also be needed.
- Otherwise, if the graph is connected and has at most 100 vertices, the Kamada-Kawai layout will be used (see
GraphBase.layout_kamada_kawai()). - Otherwise, if the graph has at most 1000 vertices, the Fruchterman-Reingold layout will be used (see
GraphBase.layout_fruchterman_reingold()). - If everything else above failed, the DrL layout algorithm will be used (see
GraphBase.layout_drl()).
All the arguments of this function except dim are passed on to the chosen layout function (in case we have to call some layout function).
Layout object.Wraps an existing layout method to ensure that it returns a Layout instead of a list of lists.
Places the vertices using a layered Sugiyama layout.
This is a layered layout that is most suitable for directed acyclic graphs, although it works on undirected or cyclic graphs as well.
Each vertex is assigned to a layer and each layer is placed on a horizontal line. Vertices within the same layer are then permuted using the barycenter heuristic that tries to minimize edge crossings.
Dummy vertices will be added on edges that span more than one layer. The returned layout therefore contains more rows than the number of nodes in the original graph; the extra rows correspond to the dummy vertices.
Undocumented