Edge

class Edge(id, vertex1, vertex2, periodicity=(0, 0, 0), position=None)[source]

Bases: object

Represents an edge in a topology graph.

Methods

clone()

Return a clone.

get_id()

Get the id of the edge.

get_periodicity()

Get the periodicity of the edge.

get_position()

Get the position.

get_vertex1_id()

Get the id of the first vertex.

get_vertex2_id()

Get the id of the second vertex.

get_vertex_ids()

Yield the ids of the vertices connected by the edge.

is_periodic()

Return True if periodic.

with_position(position)

Return a clone at position.

with_scale(scale)

Return a clone with a scaled position.

__init__(id, vertex1, vertex2, periodicity=(0, 0, 0), position=None)[source]

Initialize an Edge instance.

Parameters
  • id (int) – The id of the edge.

  • vertex1 (Vertex) – The first vertex the edge is connected to.

  • vertex2 (Vertex) – The second vertex the edge is connected to.

  • periodicity (tuple of int, optional) – The periodicity of the edge, when going from vertex1 to vertex2. For example, if (0, 0, 0) the edge is not periodic, if (1, 0, -1) the edge is periodic going in the positive direction along the x axis, is not periodic across the y axis and is periodic in the negative direction along the z axis.

  • position (numpy.ndarray, optional) – The position of the edge, if None, the midpoint of the vertices is used.

clone()[source]

Return a clone.

Returns

The clone. Has the same type as the original edge.

Return type

Edge

get_id()[source]

Get the id of the edge.

Returns

The id.

Return type

int

get_periodicity()[source]

Get the periodicity of the edge.

Returns

The periodicity of the edge. For example, if (0, 0, 0) the edge is not periodic, if (1, 0, -1) the edge is periodic going in the positive direction along the x axis, is not periodic across the y axis and is periodic in the negative direction along the z axis.

Return type

tuple of int

get_position()[source]

Get the position.

Returns

The position of the Edge.

Return type

numpy.ndarray

get_vertex1_id()[source]

Get the id of the first vertex.

Returns

The id of the first vertex.

Return type

int

get_vertex2_id()[source]

Get the id of the second vertex.

Returns

The id of the second vertex.

Return type

int

get_vertex_ids()[source]

Yield the ids of the vertices connected by the edge.

The id of the first vertex is yielded first, followed by the id of the second vertex.

Yields

int – The id of a Vertex.

is_periodic()[source]

Return True if periodic.

Returns

True if periodic.

Return type

bool

with_position(position)[source]

Return a clone at position.

Parameters

position (numpy.ndarray) – The desired position of the clone.

Returns

The clone. Has the same type as the original edge.

Return type

Edge

with_scale(scale)[source]

Return a clone with a scaled position.

Parameters

scale (float or tuple of float) – The value by which the position of the Edge is scaled. Can be a single number if all axes are scaled by the same amount or a tuple of three numbers if each axis is scaled by a different value.

Returns

The clone. Has the same type as the original edge.

Return type

Edge