Skip to main content

views

C++: phynexis::parsim::{NodeView,EdgeView,HyperEdgeView,PropertiesView} Python: phynexis.parsim.{NodeViewByIndex,NodeViewById,EdgeViewByIndex,EdgeViewById,HyperEdgeViewByIndex,HyperEdgeViewById,PropertiesView} Header: src/parsim/views/*.hpp

View classes provide indexed or ID-based access to graph elements and their properties. Each view wraps a stable reference to the underlying set and supports conversion between index-based and ID-based access.

Node Views

NodeViewByIndex(dense_index, nodes)

View a node by its contiguous (dense) index.

NodeViewById(node_id, nodes)

View a node by its stable integer ID.

Constructor Parameters:

ParameterTypeDescription
dense_index / node_idintPosition or ID in the node set
nodesNodeSetThe node set (kept alive by the view)

Methods:

MethodReturnsDescription
refresh()Re-validate the view after set mutations
is_valid()boolWhether the view points to a live node
id()intStable node ID
dense_index()intContiguous dense index
epoch()intSet modification epoch
nodes()NodeSetThe underlying node set (reference)
to_by_id()NodeViewByIdConvert to ID-based view
to_by_index()NodeViewByIndexConvert to index-based view
properties()PropertiesViewProperty accessor for this node

Cross-conversion constructors allow creating an index view from an ID view and vice versa.

Example:

import phynexis
P = phynexis.parsim

# Create a node set
g = P.ComputationalGraph()
ns = g.nodes()
# ... initialize and populate ...

# Create views
by_index = P.NodeViewByIndex(0, ns)
print("valid:", by_index.is_valid())
print("dense_index:", by_index.dense_index())

# Convert to ID-based view
by_id = P.NodeViewById(by_index.id(), ns)
print("by_id valid:", by_id.is_valid())

Output:

valid: False
dense_index: 0
by_id valid: False

Edge Views

EdgeViewByIndex(dense_index, edges)

View an edge by its dense index.

EdgeViewById(edge_id, edges)

View an edge by its stable ID.

Constructor Parameters:

ParameterTypeDescription
dense_index / edge_idintPosition or ID in the edge set
edgesEdgeSetThe edge set (kept alive by the view)

Methods:

MethodReturnsDescription
refresh()Re-validate after set mutations
is_valid()boolWhether the view is live
edge_id()intStable edge ID
dense_index()intContiguous dense index
source_node_id()intSource node ID
target_node_id()intTarget node ID
edge_type()intEdge type tag
set_edge_type(type)Set edge type
edges()EdgeSetThe underlying edge set
to_by_id() / to_by_index()Convert between access modes
properties()PropertiesViewProperty accessor

HyperEdge Views

HyperEdgeViewByIndex(dense_index, hyper_edges)

View a hyperedge by dense index.

HyperEdgeViewById(hyper_edge_id, hyper_edges)

View a hyperedge by stable ID.

Methods:

MethodReturnsDescription
refresh()Re-validate after set mutations
is_valid()boolWhether the view is live
hyper_edge_id()intStable hyperedge ID
dense_index()intContiguous dense index
hyper_edges()HyperEdgeSetThe underlying set
to_by_id() / to_by_index()Convert between access modes
properties()PropertiesViewProperty accessor
to_json()dictSerialize to JSON
from_json(j)Deserialize from JSON

PropertiesView

Generic property accessor for node/edge/hyperedge views. Provides dict-style access to field values and field manager introspection.

Methods:

MethodReturnsDescription
field_manager()FieldManagerGet the underlying field manager
dense_index()intCurrent dense index
is_valid()boolWhether the view is valid
to_json()dictSerialize all properties to JSON
from_json(j)Deserialize all properties from JSON
print_info()Print schema information

Dict-style access:

MethodDescription
pv["name"]Get property value by name
pv["name"] = valueSet property value by name

Example:

import phynexis
P = phynexis.parsim

# Access properties through node view
g = P.ComputationalGraph()
ns = g.nodes()
nvi = P.NodeViewByIndex(0, ns)
pv = nvi.properties()

print("valid:", pv.is_valid())
print("field_manager:", type(pv.field_manager()).__name__)

Output:

valid: False
field_manager: FieldManager