flpq_data.tools.stored_reverse_forward#

stored_reverse_forward(stem: str, stems: Set[str]) → str | None[source]#

Return the forward label of a stored reversed matrix stem, if any.

A matrix stem is a stored reverse when its forward label is also stored: the unindexed form L_r (forward L) or the indexed form <base>_r_<n> (forward <base>_<n>). Reversed edges must not be stored — they are auto-generated (see flpq_data.graphs.utils.add_reverse_edges()).

Parameters:
stemstr

The file stem (name without the .mtx suffix).

stemsSet[str]

The stems of all label matrices stored in the graph/ directory.

Returns:
forwardstr or None

The forward label stem reverses, or None when stem is not a stored reverse.

Examples

>>> stored_reverse_forward("a_r", {"a", "a_r"})
'a'
>>> stored_reverse_forward("load_r_0", {"load_0", "load_r_0"})
'load_0'
>>> stored_reverse_forward("load_r_0", {"load_r_0"}) is None
True