Layout-related code in the igraph library.
This package contains the implementation of the
||Represents the layout of a graph.|
||Creates an alias for the 3D version of the given layout algoritm.|
||Returns the layout of the graph according to a layout algorithm.|
||Chooses and runs a suitable layout function based on simple topological properties of the graph.|
||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.|
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.
|func||must be a method of the Graph object.|
|a new method|
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
- bipartite: bipartite layout (see
- circle, circular: circular layout (see
- dh, davidson_harel: Davidson-Harel layout (see
- drl: DrL layout for large graphs (see
- drl_3d: 3D DrL layout for large graphs (see
- fr, fruchterman_reingold: Fruchterman-Reingold layout (see
- fr_3d, fr3d, fruchterman_reingold_3d: 3D Fruchterman- Reingold layout (see
- grid: regular grid layout in 2D (see
- grid_3d: regular grid layout in 3D (see
- graphopt: the graphopt algorithm (see
- kk, kamada_kawai: Kamada-Kawai layout (see
- kk_3d, kk3d, kamada_kawai_3d: 3D Kamada-Kawai layout (see
- lgl, large, large_graph: Large Graph Layout (see
- mds: multidimensional scaling layout (see
- random: random layout (see
- random_3d: random 3D layout (see
- rt, tree, reingold_tilford: Reingold-Tilford tree layout (see
- rt_circular, reingold_tilford_circular: circular Reingold-Tilford tree layout (see
- sphere, spherical, circle_3d, circular_3d: spherical layout (see
- star: star layout (see
- sugiyama: Sugiyama layout (see
|layout||the layout to use. This can be one of the registered layout names or a callable which returns either a |
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
- Otherwise, if the graph has at most 1000 vertices, the Fruchterman-Reingold layout will be used (see
- If everything else above failed, the DrL layout algorithm will be used (see
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).
|dim||specifies whether we would like to obtain a 2D or a 3D layout.|
Wraps an existing layout method to ensure that it returns a Layout instead of a list of lists.
|func||the method to wrap. Must be a method of the Graph object.|
|a new method|
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.
|layers||a vector specifying a non-negative integer layer index for each vertex, or the name of a numeric vertex attribute that contains the layer indices. If None, a layering will be determined automatically. For undirected graphs, a spanning tree will be extracted and vertices will be assigned to layers using a breadth first search from the node with the largest degree. For directed graphs, cycles are broken by reversing the direction of edges in an approximate feedback arc set using the heuristic of Eades, Lin and Smyth, and then using longest path layering to place the vertices in layers.|
|weights||edge weights to be used. Can be a sequence or iterable or even an edge attribute name.|
|hgap||minimum horizontal gap between vertices in the same layer.|
|vgap||vertical gap between layers. The layer index will be multiplied by vgap to obtain the Y coordinate.|
|maxiter||maximum number of iterations to take in the crossing reduction step. Increase this if you feel that you are getting too many edge crossings.|
|return||specifies that the extended graph with the added dummy vertices should also be returned. When this is True, the result will be a tuple containing the layout and the extended graph. The first |V| nodes of the extended graph will correspond to the nodes of the original graph, the remaining ones are dummy nodes. Plotting the extended graph with the returned layout and hidden dummy nodes will produce a layout that is similar to the original graph, but with the added edge bends. The extended graph also contains an edge attribute called _original_eid which specifies the ID of the edge in the original graph from which the edge of the extended graph was created.|
|the calculated layout, which may (and usually will) have more rows than the number of vertices; the remaining rows correspond to the dummy nodes introduced in the layering step. When return_extended_graph is True, it will also contain the extended graph.|
|Unknown Field: newfield|
|Unknown Field: ref|
|K Sugiyama, S Tagawa, M Toda: Methods for visual understanding of hierarchical system structures. IEEE Systems, Man and Cybernetics 11(2):109-125, 1981.|
|P Eades, X Lin and WF Smyth: A fast effective heuristic for the feedback arc set problem. Information Processing Letters 47:319-323, 1993.|