circle_pack#

circle_pack(internal, external)#

Compute a circle packing layout given prescribed tangencies.

Internal circles are surrounded by a cycle of other circles; external circles have fixed radii.

Parameters:
  • internal (dict[str, list[str]]) – Mapping of internal keys to cyclic list of neighbor keys.

  • external (dict[str, float]) – Mapping of external keys to fixed radii.

Returns:

A dictionary mapping each key to a (center, radius) pair.

Raises:

ValueError – If keys are not disjoint or external radii are non-positive.

Return type:

dict[str, tuple[complex, float]]

Example

>>> internal = {'A': ['B', 'C', 'D']}
>>> external = {'B': 1.0, 'C': 1.0, 'D': 1.0}
>>> packing = circle_pack(internal, external)
>>> len(packing)
4