Graph Algorithms¶
The voids.graph sub-package provides graph-theoretic utilities operating on the
pore-throat topology stored in a Network.
Connectivity¶
voids.graph.connectivity
¶
adjacency_matrix
¶
Build the undirected pore adjacency matrix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
net
|
Network
|
Network whose pore connectivity is to be represented. |
required |
Returns:
| Type | Description |
|---|---|
csr_matrix
|
Sparse symmetric matrix |
Source code in src/voids/graph/connectivity.py
connected_components
¶
Compute connected components of the pore graph.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
net
|
Network
|
Network whose pore graph is analyzed. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Number of connected components. |
ndarray
|
Integer component labels with shape |
Source code in src/voids/graph/connectivity.py
spanning_component_ids
¶
Return component identifiers that span a given sample axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
net
|
Network
|
Network to analyze. |
required |
axis
|
str
|
Axis whose inlet and outlet boundaries define the spanning criterion. |
required |
labels
|
ndarray | None
|
Optional precomputed connected-component labels. |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Sorted array of component identifiers touching both the inlet and outlet boundary sets for the requested axis. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If the required inlet or outlet labels are missing. |
Source code in src/voids/graph/connectivity.py
spanning_component_mask
¶
Return a pore mask selecting axis-spanning connected components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
net
|
Network
|
Network to analyze. |
required |
axis
|
str
|
Axis whose boundary labels define the spanning criterion. |
required |
labels
|
ndarray | None
|
Optional precomputed connected-component labels. |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Boolean array with shape |
Source code in src/voids/graph/connectivity.py
induced_subnetwork
¶
Return the induced subnetwork associated with a pore subset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
net
|
Network
|
Network to subset. |
required |
pore_mask
|
ndarray
|
Boolean mask with shape |
required |
Returns:
| Type | Description |
|---|---|
tuple
|
|
Source code in src/voids/graph/connectivity.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
spanning_subnetwork
¶
Return the induced subnetwork formed by axis-spanning components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
net
|
Network
|
Network to subset. |
required |
axis
|
str
|
Axis whose inlet/outlet labels define the spanning criterion. |
required |
labels
|
ndarray | None
|
Optional connected-component labels. |
None
|
Returns:
| Type | Description |
|---|---|
tuple
|
|
Source code in src/voids/graph/connectivity.py
Incidence¶
voids.graph.incidence
¶
incidence_matrix
¶
Build the throat-to-pore incidence matrix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
net
|
Network
|
Network whose incidence structure is requested. |
required |
Returns:
| Type | Description |
|---|---|
csr_matrix
|
Sparse matrix |
Notes
The orientation is arbitrary but fixed by the ordering in
net.throat_conns. This is sufficient to define discrete pressure
differences and fluxes consistently.
Source code in src/voids/graph/incidence.py
Metrics¶
voids.graph.metrics
¶
ConnectivitySummary
dataclass
¶
Summarize graph-level connectivity statistics for a pore network.
Attributes:
| Name | Type | Description |
|---|---|---|
n_components |
int
|
Number of connected components in the pore graph. |
giant_component_fraction |
float
|
Fraction of pores belonging to the largest connected component. |
isolated_pore_fraction |
float
|
Fraction of pores with coordination number zero. |
dead_end_fraction |
float
|
Fraction of pores with coordination number one. |
mean_coordination |
float
|
Mean pore coordination number. |
coordination_histogram |
dict[int, int]
|
Histogram mapping coordination number to pore count. |
spans |
dict[str, bool]
|
Dictionary indicating whether any component spans each principal axis. |
Source code in src/voids/graph/metrics.py
coordination_numbers
¶
Compute pore coordination numbers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
net
|
Network
|
Network whose pore degrees are requested. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Integer array with shape |
Source code in src/voids/graph/metrics.py
connectivity_metrics
¶
Compute a compact set of connectivity diagnostics for a pore graph.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
net
|
Network
|
Network to analyze. |
required |
Returns:
| Type | Description |
|---|---|
ConnectivitySummary
|
Aggregate summary of component counts, degree statistics, and axis spanning information. |