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
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
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
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
Get filtered node IDs (cached).
Returns:
| Type | Description |
|---|---|
set[str] | None
|
None means no node filter (full graph). |
edge_ids
property
Get filtered edge IDs (cached).
Returns:
| Type | Description |
|---|---|
set[str] | None
|
None means no edge filter (full graph). |
node_count
property
Return the number of nodes 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
Return an edge DataFrame view filtered to this view's edges.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Passed through to |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame - like
|
|
Notes
Uses AnnNet.edges_view() and then filters by the view's edge IDs.
nodes_df
Return a node DataFrame view filtered to this view's nodes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Passed through to |
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame - like
|
|
Notes
Uses AnnNet.nodes_view() and then filters by the view's node IDs.
materialize
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
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.
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
|
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: |
None
|
in_slice
|
str
|
Keep only the rows of this slice. Distinct from |
None
|
include_hyper
|
bool
|
Include hyperedges. |
True
|
include_binary
|
bool
|
Include binary edges. |
True
|
Returns:
| Type | Description |
|---|---|
DataFrame - like
|
|
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
Read-only node attribute table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
copy
|
bool
|
Return a cloned DataFrame. |
True
|
Returns:
| Type | Description |
|---|---|
DataFrame - like
|
Columns include |
slices_view
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
|
aspects_view
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
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
hyperedges
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
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.