Skip to content

Slices

Slice management from annnet.core._Slices.

Use G.slices and the AnnNet slice methods for slice workflows. Direct imports from underscore modules follow the internal API policy.

annnet.core._Slices.SliceManager

Namespace for all slice operations.

Owns the full slice implementation — SliceClass on AnnNet is a thin forwarding shell kept for callers that cannot be updated (e.g. adapters). State (_slices, _current_slice, _default_slice, slice_edge_weights) lives on AnnNet because it is accessed pervasively in core graph methods.

Functions

add_slice
add_slice(slice_id, **attributes)

Create a new empty slice.

Parameters:

Name Type Description Default
slice_id str
required
**attributes

Slice attributes.

{}

Returns:

Type Description
str
remove
remove(slice_id)

Remove a non-default slice.

remove_slice
remove_slice(slice_id)

Remove a non-default slice and its per-slice attributes.

Parameters:

Name Type Description Default
slice_id str
required

Raises:

Type Description
ValueError

If attempting to remove the internal default slice.

KeyError

If the slice does not exist.

add_edge_to_slice
add_edge_to_slice(lid, eid)

Attach an existing edge to a slice (no weight changes).

Parameters:

Name Type Description Default
lid str
required
eid str
required

Raises:

Type Description
KeyError

If the slice does not exist.

add_edges
add_edges(slice_id, edge_ids)

Attach many existing edges to a slice and include their incident vertices.