Edges

Base module for the edges of a polyhex

class polyhex.objects.edges.HexagonEdge(hexagon: Hexagon, start: HexagonVertex, end: HexagonVertex, index: int, feature: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] = 'placeholder')

Bases: object

HexagonEdge class.

Parameters:
  • hexagon (Hexagon) – the hexagon to which the edge’s belong

  • start (HexagonVertex) – the start vertex

  • end (HexagonVertex) – the end vertex

  • index (int) – the edge’s index in the hexagon (0 to 5)

  • feature (ArrayLike) – the edge’s feature

  • free (bool) – Identifies if there is something on the edge. Defaults to False.

  • token (ArrayLike) – Identifies what is on the edge. Defaults to None

distance(other, kwd='path')

Method to compute the distance between two edges.

Parameters:
  • other (HexagonEdge) – other HexagonEdge

  • kwd (str, optional) – kwd identifier of the distance. Defaults to “path”.

Raises:

NotImplementedError – f’The distance method is only implemented for the kwd path.

Returns:

0 or 1

Return type:

int

draw(save=True)

The draw function is a convenience function that wraps the render function. It is used for standalone drawing and generates a figure which is saved based on the save boolean argument

Parameters:

save (bool, optional) – _description_. Defaults to True.

property encoding

it turns the string representation of the feature and the token into a list.

Returns:

vector encoding of the edge’s representation

Return type:

(list)

Type:

The encoding is an attribute of an edge

end: HexagonVertex
feature: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] = 'placeholder'
hexagon: Hexagon
index: int
render(axes: Artist, **kwargs)

The render method is a public method. It is used for display and differs from draw as it requires a matplotlib.axe and returns a matplotlib.axe :param axes: matplotlib.Artist on which to draw :type axes: Artist :param kwargs: keyword dict that can replace the default rendering options defined in the assets.

Returns:

matplotlib.Artist on which the edge was rendered

Return type:

axes (Artist)

render_line(axes, **kwargs)

Method to render the body of an edge. It is used in conjunction with render_triangle that draws the background of an hexagon, in the triangle in the edge’s end, start and Hexagon’s centre node.

Parameters:

axes (Artist) – matplotlib.Artist on which to draw

Returns:

matplotlib.Artist on which the edge was rendered

Return type:

axes (Artist)

render_triangle(axes, **kwargs)

Method to render the background of an hexagon, in the triangle in the edge’s end, start and Hexagon’s centre node. It is used in conjunction with render_line that draws the edge’s body

Parameters:

axes (Artist) – matplotlib.Artist on which to draw

Returns:

matplotlib.Artist on which the edge was rendered

Return type:

axes (Artist)

start: HexagonVertex