Skip to content

Views

View helpers from annnet.core._Views.

Use G.view(...) for graph view workflows. Direct imports from underscore modules follow the internal API policy.

annnet.core._Views.GraphView

Lazy, filtered view into a graph; materialize() for a concrete subgraph.

Attributes

obs property
obs

Return the filtered node attribute table for this view.

Returns:

Type Description
DataFrame - like
Notes

Materialized from the node table of the graph and filtered by the node ids of this view. It is a table for the caller, not the storage of the graph.

var property
var

Return the filtered edge attribute table for this view.

Returns:

Type Description
DataFrame - like
Notes

Materialized from the edge table of the graph and filtered by the edge ids of this view. It is a table for the caller, not the storage of the graph.

B property
B

Return the filtered incidence matrix subview.

Named as the graph names it. X was the spelling of the incidence matrix before cycle 002 renamed it, and it stayed here after it went from the graph, so one object answered to a name the other refused.

Returns:

Type Description
dok_matrix
node_ids property
node_ids

Get filtered node IDs (cached).

Returns:

Type Description
set[str] | None

None means no node filter (full graph).

edge_ids property
edge_ids

Get filtered edge IDs (cached).

Returns:

Type Description
set[str] | None

None means no edge filter (full graph).

node_count property
node_count

Return the number of nodes in this view.

Returns:

Type Description
int
edge_count property
edge_count

Return the number of edges in this view.

Returns:

Type Description
int

Functions

edges_df
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.

nodes_df
nodes_df(**kwargs)

Return a node DataFrame view filtered to this view's nodes.

Parameters:

Name Type Description Default
**kwargs

Passed through to AnnNet.nodes_view().

{}

Returns:

Type Description
DataFrame - like
Notes

Uses AnnNet.nodes_view() and then filters by the view's node IDs.

materialize
materialize(copy_attributes=True)

Create a concrete subgraph from this view.

Parameters:

Name Type Description Default
copy_attributes bool

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

True

Returns:

Type Description
AnnNet

Materialized subgraph.

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

Create a new GraphView by further restricting this view.

Parameters:

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

Node 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 node predicate applied in conjunction with existing filters.

None

Returns:

Type Description
GraphView
Notes

Predicates are combined with logical AND.

summary
summary()

Return a human-readable summary of this view.

Returns:

Type Description
str

annnet.core._Views.ViewsClass

Materialized table builders mixed into AnnNet.

Functions

edges_view
edges_view(
    slice=None,
    include_directed=True,
    include_weight=True,
    resolved_weight=True,
    copy=True,
    *,
    layer=None,
    in_slice=None,
    include_hyper=True,
    include_binary=True
)

Build a DataFrame view of edges with optional slice join.

Parameters:

Name Type Description Default
slice str

Slice id whose per-edge attributes are joined onto every row, as slice_* columns. This does not filter — see in_slice.

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
layer tuple[str, ...]

Keep only the edges of this layer, as :meth:LayerAccessor.layer_edge_set names them.

None
in_slice str

Keep only the rows of this slice. Distinct from slice, which joins without filtering.

None
include_hyper bool

Include hyperedges. False leaves a table whose rows are all binary, which is what an exporter that cannot hold a hyperedge wants.

True
include_binary bool

Include binary edges. False with include_hyper leaves the hyperedges alone — which is what :meth:ViewsAccessor.hyperedges asks for.

True

Returns:

Type Description
DataFrame - like

source and target are bare node ids; src_layer and dst_layer are the canonical layer ids of the two endpoints, and are null when the graph is flat or a side does not sit in one layer.

Notes

slice= joins, in_slice= filters. Both take a slice id and they do different things, so a call that means "only this slice's edges" wants the second.

nodes_view
nodes_view(copy=True)

Read-only node attribute table.

Parameters:

Name Type Description Default
copy bool

Return a cloned DataFrame.

True

Returns:

Type Description
DataFrame - like

Columns include node_id plus pure attributes.

slices_view
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

One row per slice (including the default slice), keyed by slice_id. User-set slice attributes appear as additional columns; slices without user attrs still appear, with null cells.

aspects_view
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
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.

annnet.core._Views.ViewsAccessor

Namespace for materialized graph tables (G.views).

Functions

edges
edges(*args, **kwargs)

Materialize the edge table view.

hyperedges
hyperedges(
    slice=None, copy=True, *, layer=None, in_slice=None
)

Materialize the hyperedge table view.

The same table :meth:edges builds, holding only the rows whose kind is "hyper". head, tail and members are the columns that carry a hyperedge's shape, and they are null on every binary row — which is why reading hyperedges out of the full table means filtering it first.

Parameters:

Name Type Description Default
slice str

Slice id whose per-edge attributes are joined onto every row.

None
copy bool

Return a cloned DataFrame if True.

True
layer tuple[str, ...]

Keep only the hyperedges of this layer.

None
in_slice str

Keep only the rows of this slice.

None

Returns:

Type Description
DataFrame - like
entity_kinds
entity_kinds()

Return the kind of every entity, as a mapping from its id.

An entity is a node, or an edge that is a node in its own right. The answer is built on each call, so changing it changes nothing.

nodes
nodes(*args, **kwargs)

Materialize the node table view.

slices
slices(*args, **kwargs)

Materialize the slice table view.

aspects
aspects(*args, **kwargs)

Materialize the aspect table view.

layers
layers(*args, **kwargs)

Materialize the layer table view.

layers_view
layers_view(copy=True)

Materialize the layer table view.