Skip to main content
Version: latest

agrag.common.data_models.structure.common_ancestor

common_ancestor(sections:list[DocumentSection], indexes:list[int]) -> int | None

Return the lowest section that contains all the given sections.

Parameters:

  • sections (list[DocumentSection]) – The sections of a document.
  • indexes (list[int]) – The indexes of the sections to contain. A section contains itself. Must not be empty.

Returns:

  • int | None – The index of the section, or None when only the document contains them.

Raises:

  • ValueError – indexes is empty, or an index is outside sections.