Skip to content

Views

View helpers from annnet.core._Views.

annnet.core._Views.GraphView

Lazy view into a graph with deferred operations.

Provides filtered access to graph components without copying the underlying data. Views can be materialized into concrete subgraphs when needed.

Parameters:

Name Type Description Default
graph AnnNet

Parent graph instance

required
vertices list[str] | set[str] | callable | None

vertex IDs to include, or predicate function

None
edges list[str] | set[str] | callable | None

Edge IDs to include, or predicate function

None
slices str | list[str] | None

slice ID(s) to include

None
predicate callable | None

Additional filter: predicate(vertex_id) -> bool

None

Attributes

obs property

Return the filtered vertex attribute table for this view.

Returns:

Type Description
DataFrame - like
Notes

Uses AnnNet.vertex_attributes and filters by the view's vertex IDs.

var property

Return the filtered edge attribute table for this view.

Returns:

Type Description
DataFrame - like
Notes

Uses AnnNet.edge_attributes and filters by the view's edge IDs.

X property

Return the filtered incidence matrix subview.

Returns:

Type Description
dok_matrix
vertex_ids property

Get filtered vertex IDs (cached).

Returns:

Type Description
set[str] | None

None means no vertex filter (full graph).

edge_ids property

Get filtered edge IDs (cached).

Returns:

Type Description
set[str] | None

None means no edge filter (full graph).

vertex_count property

Return the number of vertices in this view.

Returns:

Type Description
int
edge_count property

Return the number of edges in this view.

Returns:

Type Description
int

Functions

edges_df(**kwargs)

Return an edge DataFrame view filtered to this view's edges.

Parameters:

Name Type Description Default
**kwargs

Passed through to AnnNet.edges_view().

{}

Returns:

Type Description
DataFrame - like
Notes

Uses AnnNet.edges_view() and then filters by the view's edge IDs.

vertices_df(**kwargs)

Return a vertex DataFrame view filtered to this view's vertices.

Parameters:

Name Type Description Default
**kwargs

Passed through to AnnNet.vertices_view().

{}

Returns:

Type Description
DataFrame - like
Notes

Uses AnnNet.vertices_view() and then filters by the view's vertex IDs.

materialize(copy_attributes=True)

Create a concrete subgraph from this view.

Parameters:

Name Type Description Default
copy_attributes bool

If True, copy vertex/edge attributes into the new graph.

True

Returns:

Type Description
AnnNet

Materialized subgraph.

subview(vertices=None, edges=None, slices=None, predicate=None)

Create a new GraphView by further restricting this view.

Parameters:

Name Type Description Default
vertices Iterable[str] | callable | None

Vertex IDs or predicate; intersects with current view if provided.

None
edges Iterable[str] | callable | None

Edge IDs or predicate; intersects with current view if provided.

None
slices Iterable[str] | None

Slice IDs to include. Defaults to current view's slices if None.

None
predicate callable | None

Additional vertex predicate applied in conjunction with existing filters.

None

Returns:

Type Description
GraphView
Notes

Predicates are combined with logical AND.

summary()

Return a human-readable summary of this view.

Returns:

Type Description
str

annnet.core._Views.ViewsClass

Functions

edges_view(slice=None, include_directed=True, include_weight=True, resolved_weight=True, copy=True)

Build a DataFrame view of edges with optional slice join.

Parameters:

Name Type Description Default
slice str

Slice ID to join per-slice attributes.

None
include_directed bool

Include directedness column.

True
include_weight bool

Include global weight column.

True
resolved_weight bool

Include effective weight (slice override if present).

True
copy bool

Return a cloned DataFrame if True.

True

Returns:

Type Description
DataFrame - like
Notes

Vectorized implementation avoids per-edge scans.

vertices_view(copy=True)

Read-only vertex attribute table.

Parameters:

Name Type Description Default
copy bool

Return a cloned DataFrame.

True

Returns:

Type Description
DataFrame - like

Columns include vertex_id plus pure attributes.

slices_view(copy=True)

Read-only slice attribute table.

Parameters:

Name Type Description Default
copy bool

Return a cloned DataFrame.

True

Returns:

Type Description
DataFrame - like

Columns include slice_id plus pure attributes.

aspects_view(copy=True)

Return a view of Kivela aspects and their metadata.

Parameters:

Name Type Description Default
copy bool

Return a cloned DataFrame.

True

Returns:

Type Description
DataFrame - like
Notes

Columns include aspect, elem_layers, and any aspect attribute keys.

layers_view(copy=True)

Return a read-only table of multi-aspect layers.

Parameters:

Name Type Description Default
copy bool

Return a cloned DataFrame.

True

Returns:

Type Description
DataFrame - like
Notes

Columns include layer_tuple, layer_id, aspect columns, layer attributes, and prefixed elementary layer attributes.