Local
These are utility functions used to restrict analyses to neighborhoods.
neighborhood(adj, v, pre=True, post=True, include_center=True, return_neighbors=False)
Gets the neighborhood of v in adj
Parameters:
Name | Type | Description | Default |
---|---|---|---|
adj |
sparse matrix or 2d array
|
The adjacency matrix of the graph |
required |
pre |
bool
|
If |
True
|
post |
bool
|
If |
True
|
include_center |
bool
|
If |
True
|
return_neighbors |
bool
|
If |
False
|
Returns:
Type | Description |
---|---|
matrix (sparse if adj is sparse)
|
If pre = post = If pre = If pre = If include_center = |
Source code in src/connalysis/network/local.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
|
neighborhood_indices(M, pre=True, post=True, all_nodes=True, centers=None)
Computes the indices of the neighbors of the nodes listed in centers
Parameters:
Name | Type | Description | Default |
---|---|---|---|
M |
sparse matrix or 2d array
|
The adjacency matrix of the graph |
required |
pre |
bool
|
If |
True
|
post |
bool
|
If |
True
|
all_nodes |
bool
|
If |
True
|
centers |
1d-array
|
The indices of the nodes for which the neighbors need to be computed. This entry is ignored if
all_nodes is |
None
|
Returns:
Type | Description |
---|---|
data frame
|
indices: range from 0 to values: the neighbors of each center in the indices. |
Raises:
Type | Description |
---|---|
AssertionError
|
If the matrix M is not square |
AssertionError
|
If both pre and post are |
AssertionError
|
If all_nodes is |
Source code in src/connalysis/network/local.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
|
neighborhood_of_set(M, node_set, pre=True, post=True, include_centers=True, return_neighbors=False)
Gets the neighborhood of the nodes in node_set
Parameters:
Name | Type | Description | Default |
---|---|---|---|
M |
sparse matrix or 2d array
|
The adjacency matrix of the graph |
required |
node_set |
array
|
The indices of the nodes of which the neighborhood will be computed |
required |
pre |
bool
|
If |
True
|
post |
bool
|
If |
True
|
include_center |
bool
|
If |
required |
return_neighbors |
bool
|
If |
False
|
Returns:
Type | Description |
---|---|
matrix (sparse if M is sparse)
|
If pre = post = If pre = If pre = |
Source code in src/connalysis/network/local.py
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 |
|
neighborhood_of_set_indices(M, node_set, pre=True, post=True)
Computes the indices of the neighbors of the nodes in node_set
Parameters:
Name | Type | Description | Default |
---|---|---|---|
M |
sparse matrix or 2d array
|
The adjacency matrix of the graph |
required |
pre |
bool
|
If |
True
|
post |
bool
|
If |
True
|
node_set |
1d-array
|
The indices of the nodes for which the neighbors need to be computed. |
required |
Returns:
Type | Description |
---|---|
array
|
indices of the neighbhors of node_set |
Raises:
Type | Description |
---|---|
AssertionError
|
If both pre and post are |
Source code in src/connalysis/network/local.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
|
neighbourhood(v, matrix)
Computes the matrix induced by the neighbours of v in graph with adjacency matrix matrix
Parameters:
Name | Type | Description | Default |
---|---|---|---|
v |
int
|
the index of the vertex |
required |
matrix |
matrix
|
the adjacency matrix of the graph |
required |
Returns:
Type | Description |
---|---|
matrix
|
the adjaceny matrix of the neighbourhood of v in matrix |
Source code in src/connalysis/network/local.py
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
|
neighbours(v, matrix)
Computes the neighbours of v in graph with adjacency matrix matrix
Parameters:
Name | Type | Description | Default |
---|---|---|---|
v |
int
|
the index of the vertex |
required |
matrix |
matrix
|
the adjacency matrix of the graph |
required |
Returns:
Type | Description |
---|---|
list
|
the list of neighbours of v in matrix |
Source code in src/connalysis/network/local.py
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 |
|
properties_at_neighborhoods(adj, func_config, pre=True, post=True, include_center=True, all_nodes=True, centers=None)
Computes the properties in func_config on the neighborhoods of the centers within adj
Parameters:
Name | Type | Description | Default |
---|---|---|---|
adj |
sparse matrix or 2d array
|
The adjacency matrix of the graph |
required |
func_config |
dict
|
Configuration dictionary of functions to be computed on neihgborhoods |
required |
pre |
bool
|
If |
True
|
post |
bool
|
If |
True
|
include_center |
bool
|
If |
True
|
all_nodes |
bool
|
If If |
True
|
centers |
1d-array
|
The indices of the nodes to consider. This entry is ignored if
all_nodes is |
None
|
Returns:
Type | Description |
---|---|
dict
|
keys: keys of func_config values: dict with
|
Source code in src/connalysis/network/local.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
|
property_at_neighborhoods(adj, func, pre=True, post=True, include_center=True, all_nodes=True, centers=None, **kwargs)
Computes the property func on the neighborhoods of the centers within adj
Parameters:
Name | Type | Description | Default |
---|---|---|---|
adj |
sparse matrix or 2d array
|
The adjacency matrix of the graph |
required |
func |
function
|
Function computing a network theoretic property e.g., degree or simplex counts |
required |
pre |
bool
|
If |
True
|
post |
bool
|
If |
True
|
include_center |
bool
|
If |
True
|
all_nodes |
bool
|
If If |
True
|
centers |
1d-array
|
The indices of the nodes to consider. This entry is ignored if
all_nodes is |
None
|
Returns:
Type | Description |
---|---|
dict
|
keys: range from 0 to values: the output of |
Source code in src/connalysis/network/local.py
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 221 222 223 224 225 226 227 228 229 230 231 232 233 |
|
submat_at_ind(M, ind)
Computes the submatrix of M on the nondes indexed by ind
Parameters:
Name | Type | Description | Default |
---|---|---|---|
M |
matrix
|
the adjacency matrix of the graph |
required |
ind |
1d-array
|
the indices on which to slice the matrix M |
required |
Returns:
Type | Description |
---|---|
matrix
|
the adjaceny matrix of the submatrix of M on the nodes in ind |
Source code in src/connalysis/network/local.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
|