graphistry.layout.utils package

Submodules

graphistry.layout.utils.dummyVertex module

class graphistry.layout.utils.dummyVertex.DummyVertex(r=None)

Bases: graphistry.layout.utils.layoutVertex.LayoutVertex

A DummyVertex is used for edges that span over several layers, it’s inserted in every inner layer.

Attributes
  • view (viewclass): since a DummyVertex is acting as a Vertex, it must have a view.

  • ctrl (list[_sugiyama_attr]): the list of associated dummy vertices.

inner(direction)

True if a neighbor in the given direction is dummy.

neighbors(direction)

Reflect the Vertex method and returns the list of adjacent vertices (possibly dummy) in the given direction. :type direction: int :param direction: +1 for the next layer (children) and -1 (parents) for the previous

graphistry.layout.utils.geometry module

graphistry.layout.utils.geometry.angle_between_vectors(p1, p2)
graphistry.layout.utils.geometry.lines_intersection(xy1, xy2, xy3, xy4)

Returns the intersection of two lines.

graphistry.layout.utils.geometry.new_point_at_distance(pt, distance, angle)
graphistry.layout.utils.geometry.rectangle_point_intersection(rec, p)

Returns the intersection point between the Rectangle (w,h) that characterize the rec object and the line that goes from the recs’ object center to the ‘p’ point.

graphistry.layout.utils.geometry.set_round_corner(e, pts)
graphistry.layout.utils.geometry.setcurve(e, pts, tgs=None)

Returns the spline curve that path through the list of points P. The spline curve is a list of cubic bezier curves (nurbs) that have matching tangents at their extreme points. The method considered here is taken from “The NURBS book” (Les A. Piegl, Wayne Tiller, Springer, 1997) and implements a local interpolation rather than a global interpolation.

Args:

e: pts: tgs:

Returns:

graphistry.layout.utils.geometry.size_median(recs)
graphistry.layout.utils.geometry.tangents(P, n)

graphistry.layout.utils.layer module

class graphistry.layout.utils.layer.Layer(iterable=(), /)

Bases: list

Layer is where Sugiyama layout organises vertices in hierarchical lists. The placement of a vertex is done by the Sugiyama class, but it highly relies on the ordering of vertices in each layer to reduce crossings. This ordering depends on the neighbors found in the upper or lower layers.

Attributes:

layout (SugiyamaLayout): a reference to the sugiyama layout instance that contains this layer upper (Layer): a reference to the upper layer (layer-1) lower (Layer): a reference to the lower layer (layer+1) crossings (int) : number of crossings detected in this layer

Methods:

setup (layout): set initial attributes values from provided layout nextlayer(): returns next layer in the current layout’s direction parameter. prevlayer(): returns previous layer in the current layout’s direction parameter. order(): compute optimal ordering of vertices within the layer.

crossings = None
layout = None
lower = None
neighbors(v)

neighbors refer to upper/lower adjacent nodes. Note that v.neighbors() provides neighbors of v in the graph, while this method provides the Vertex and DummyVertex adjacent to v in the upper or lower layer (depending on layout.dirv state).

nextlayer()
order()
prevlayer()
setup(layout)
upper = None

graphistry.layout.utils.layoutVertex module

class graphistry.layout.utils.layoutVertex.LayoutVertex(layer=None, is_dummy=0)

Bases: object

The Sugiyama layout adds new attributes to vertices. These attributes are stored in an internal _sugimyama_vertex_attr object.

Attributes:

layer (int): layer number dummy (0/1): whether the vertex is a dummy pos (int): the index of the vertex within the layer x (list(float)): the list of computed horizontal coordinates of the vertex bar (float): the current barycenter of the vertex

Parameters

layer (Optional[int]) –

graphistry.layout.utils.poset module

class graphistry.layout.utils.poset.Poset(collection=[])

Bases: object

Poset class implements a set but allows to integrate over the elements in a deterministic way and to get specific objects in the set. Membership operator defaults to comparing __hash__ of objects but Poset allows to check for __cmp__/__eq__ membership by using contains__cmp__(obj)

add(obj)
contains__cmp__(obj)
copy()
deepcopy()
difference(*args)
get(obj)
index(obj)
intersection(*args)
issubset(other)
issuperset(other)
remove(obj)
symmetric_difference(*args)
union(other)
update(other)

graphistry.layout.utils.rectangle module

class graphistry.layout.utils.rectangle.Rectangle(w=1, h=1)

Bases: object

Rectangular region.

graphistry.layout.utils.routing module

class graphistry.layout.utils.routing.EdgeViewer

Bases: object

setpath(pts)
graphistry.layout.utils.routing.route_with_lines(e, pts)

Basic edge routing with lines. The layout pass has already provided to list of points through which the edge shall be drawn. We just compute the position where to adjust the tail and head.

graphistry.layout.utils.routing.route_with_rounded_corners(e, pts)
graphistry.layout.utils.routing.route_with_splines(e, pts)

Enhanced edge routing where ‘corners’ of the above polyline route are rounded with a Bezier curve.

Module contents