class Layout:
Represents the layout of a graph.
A layout is practically a list of coordinates in an n-dimensional space. This class is generic in the sense that it can store coordinates in any n-dimensional space.
Layout objects are not associated directly with a graph. This is deliberate: there were times when I worked with almost identical copies of the same graph, the only difference was that they had different colors assigned to the vertices. It was particularly convenient for me to use the same layout for all of them, especially when I made figures for a paper. However, igraph will of course refuse to draw a graph with a layout that has less coordinates than the node count of the graph.
Layouts behave exactly like lists when they are accessed using the item index operator ([...]). They can even be iterated through. Items returned by the index operator are only copies of the coordinates, but the stored coordinates can be modified by directly assigning to an index.
>>> layout = Layout([(0, 1), (0, 2)]) >>> coords = layout[1] >>> print(coords) [0, 2] >>> coords = (0, 3) >>> print(layout[1]) [0, 2] >>> layout[1] = coords >>> print(layout[1]) [0, 3]
__copy__
Undocumented
__delitem__
Undocumented
__getitem__
Undocumented
__init__
Constructor.
__len__
Undocumented
__repr__
Undocumented
__setitem__
Undocumented
append
Appends a new point to the layout
boundaries
Returns the boundaries of the layout.
bounding_box
Returns the bounding box of the layout.
center
Centers the layout around the given point.
centroid
Returns the centroid of the layout.
copy
Creates an exact copy of the layout.
fit_into
Fits the layout into the given bounding box.
mirror
Mirrors the layout along the given dimension(s)
rotate
Rotates the layout by the given degrees on the plane defined by the given two dimensions.
scale
Scales the layout.
to_radial
Converts a planar layout to a radial one
transform
Performs an arbitrary transformation on the layout
translate
Translates the layout.
coords
The coordinates as a list of lists
dim
Returns the number of dimensions
_coords
Undocumented
_dim
Undocumented
Undocumented
Undocumented
Undocumented
Constructor.
Undocumented
Undocumented
Undocumented
Appends a new point to the layout
Returns the boundaries of the layout.
The boundaries are the minimum and maximum coordinates along all dimensions.
ValueError if the layout contains no layout itemsReturns the bounding box of the layout.
The bounding box of the layout is the smallest box enclosing all the points in the layout.
BoundingBox object.Centers the layout around the given point.
The point itself can be supplied as multiple unnamed arguments, as a simple unnamed list or as a keyword argument. This operation moves the centroid of the layout to the given point. If no point is supplied, defaults to the origin of the coordinate system.
Returns the centroid of the layout.
The centroid of the layout is the arithmetic mean of the points in the layout.
Creates an exact copy of the layout.
Fits the layout into the given bounding box.
The layout will be modified in-place.
BoundingBox object (for 2D layouts only).Mirrors the layout along the given dimension(s)
Rotates the layout by the given degrees on the plane defined by the given two dimensions.
Scales the layout.
Scaling parameters can be provided either through the scale keyword argument or through plain unnamed arguments. If a single integer or float is given, it is interpreted as a uniform multiplier to be applied on all dimensions. If it is a list or tuple, its length must be equal to the number of dimensions in the layout, and each element must be an integer or float describing the scaling coefficient in one of the dimensions.
Converts a planar layout to a radial one
This method applies only to 2D layouts. The X coordinate of the layout is transformed to an angle, with min(x) corresponding to the parameter called min_angle and max(y) corresponding to max_angle. Angles are given in degrees, zero degree corresponds to the direction pointing upwards. The Y coordinate is interpreted as a radius, with min(y) belonging to the minimum and max(y) to the maximum radius given in the arguments.
This is not a fully generic polar coordinate transformation, but it is fairly useful in creating radial tree layouts from ordinary top-down ones (that's why the Y coordinate belongs to the radius). It can also be used in conjunction with the Fruchterman-Reingold layout algorithm via its miny and maxy parameters (see Graph.layout_fruchterman_reingold() ) to produce radial layouts where the radius belongs to some property of the vertices.
Performs an arbitrary transformation on the layout
Additional positional and keyword arguments are passed intact to the given function.
Translates the layout.
The translation vector can be provided either through the v keyword argument or through plain unnamed arguments. If unnamed arguments are used, the vector can be supplied as a single list (or tuple) or just as a series of arguments. In all cases, the translation vector must have the same number of dimensions as the layout.
The coordinates as a list of lists
Returns the number of dimensions
Undocumented
Undocumented