abstractsimplicialcomplex
AbstractSimplicialComplex
Bases: UserList
Embodies the concept of abstract simplicial complex.
Abstract Simplicial Complexes, ASC, are closed set of elements that are topologically related. No geometrical properties are considered here.
Source code in src/dxtr/complexes/abstractsimplicialcomplex.py
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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 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 128 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 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 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 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 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 | |
dim
property
Gets the topologic dimension of the complex.
Returns:
| Type | Description |
|---|---|
int
|
The topologic dimension of the complex. |
euler_characteristic
property
Computes the Euler characteristic of the complex.
Returns:
| Type | Description |
|---|---|
int
|
The Euler characteristic of the complex. |
Notes
- The Euler characteristic (chi) of a CW-complex is given by: chi = sum_i((-1)^i * #splx_i)
isclosed
property
Tests if the n-complex is homeomorphic to a n-ball.
Returns:
| Type | Description |
|---|---|
bool
|
True if the complex is homeomorphic to a n-ball, False otherwise. |
Notes
- The name of this property is confusing for it tests if the complex is homeomorphic to a ball. For instance, a torus would return False.
- Maybe a better definition would be based on Betty numbers?
- The Euler characteristics of a n-dimensional ball is 1 + (-1)**n.
See also
- The wikipedia page on euler characteristics,
its a start...
ispure
property
Checks if the considered simplicial complex is pure.
Returns:
| Type | Description |
|---|---|
bool
|
True if the complex is pure, False otherwise. |
Notes
- A simplicial n-complex is said pure iff every k-simplices within it is a face of at least one n-simplex.
- For more insight, see: course by Keenan Crane.
name
property
writable
Gets the name of the complex.
Returns:
| Type | Description |
|---|---|
str
|
The name of the complex. |
shape
property
Gets the numbers of simplices for each dimension.
Returns:
| Type | Description |
|---|---|
tuple of int
|
The numbers of simplices for each dimension. |
__contains__(other)
Checks if one abstract simplicial complex contains another one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
AbstractSimplicialComplex
|
The other abstract simplicial complex to check. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the other abstract simplicial complex is contained, False otherwise. |
Examples:
>>> asc0 = AbstractSimplicialComplex([[1,2,3,4]])
>>> asc1 = AbstractSimplicialComplex([[1,2,4]])
>>> asc1 in asc0
True
Source code in src/dxtr/complexes/abstractsimplicialcomplex.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
__init__(indices, name=None)
Initializes an AbstractSimplicialComplex object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indices
|
list of list of int
|
The list of vertex indices forming the highest degree simplices. |
required |
name
|
str
|
A name for the complex. |
None
|
Source code in src/dxtr/complexes/abstractsimplicialcomplex.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
__str__()
Returns the name of the complex.
Returns:
| Type | Description |
|---|---|
str
|
The name of the complex. |
Source code in src/dxtr/complexes/abstractsimplicialcomplex.py
72 73 74 75 76 77 78 79 80 | |
adjacency_tensor(k, l)
Returns the vertex-based adjacency between k, l & k+l simplices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
k
|
int
|
The first topological dimension to consider. |
required |
l
|
int
|
The second topological dimension to consider. |
required |
Returns:
| Type | Description |
|---|---|
sparse.COO of int
|
A 3rd-order tensor filled with 0, 1 & -1 |
Notes
- This method is needed to compute the wedge product between
Cochaininstances. - This method uses the
COOclass from thesparselibrary. Because implementing such a tensor in its dense version innumpywould have been too costing for large structures and higher-order sparse arrays at not yet available inscpipy.sparse.
Source code in src/dxtr/complexes/abstractsimplicialcomplex.py
645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 | |
border(simplices=None)
Gets the subcomplex boundary of a pure complex.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
simplices
|
dict of int to list of int
|
The list of simplex indices forming the chain we want the border of. If None, the whole ASC is considered. |
None
|
Returns:
| Type | Description |
|---|---|
dict of int to list of int, optional
|
The keys are topological dimensions k. The values are lists of the k-simplex indices belonging to the seeked border ensemble. |
Notes
- If no simplices are specified, the whole ASC is considered.
- To simplicify we only compute borders for pure complexes.
- The provided indices should specify a pure (sub-)complex.
- 0-simplices are considered to be their own borders.
- If the provided complex is closed, the output is None.
Source code in src/dxtr/complexes/abstractsimplicialcomplex.py
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 | |
build_topology(indices)
Computes all faces and incidence matrices from the given simplices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indices
|
list of list of int
|
List of the vertex indices forming the highest degree simplices. |
required |
Notes
- This method is the heart of the
AbstractSimplicialComplexclass. - It computes the simplices of all degrees from the list of the highest degree ones.
- It also computes a coherent orientation for the top simplices.
Source code in src/dxtr/complexes/abstractsimplicialcomplex.py
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | |
closure(simplices, dim=None)
Gets the smallest simplicial complex containing the given simplices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
simplices
|
dict of int to list of int or list of int or int
|
The list of simplex indices forming the chain we want the closure of. |
required |
dim
|
int
|
The topological dimension of the simplices we want the closure of. |
None
|
Returns:
| Type | Description |
|---|---|
dict of int to list of int
|
The keys are topological dimensions k. The values are lists of the k-simplex indices belonging to the seeked closure ensemble. |
Notes
- See the
.math.topologymodule for details.
Source code in src/dxtr/complexes/abstractsimplicialcomplex.py
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 | |
cofaces(simplex_dim, coface_dim=None, ordered=False)
Returns the list of k'-coface indices for all k-simplices (k'>k).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
simplex_dim
|
int
|
The topological dimension of the considered simplices. |
required |
coface_dim
|
int
|
The topological dimension of the desired cofaces. Default is simplex_dim+1. |
None
|
ordered
|
bool
|
If True, for each simplex, the coface indices are returned in the following order so we can loop around from one coface to the neighboring one. Default is False. |
False
|
Returns:
| Type | Description |
|---|---|
list of list of int
|
The list of coface indices for all simplices in the considered k-Module. |
Notes
- The parameters must verify: 0<=simplex_dim<=coface_dim<=self.dim
- This method may seem redundant with the
starmethod. Actually, it is meant to be applied globally on the whole complex while thestarmethod is designed to be applied on small subsets of simplices. - Its design makes it much faster and therefore suitable for processing the whole structure at once, especially during instantiation.
Source code in src/dxtr/complexes/abstractsimplicialcomplex.py
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 | |
faces(simplex_dim, face_dim=None)
Returns the list of face indices for all k-simplices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
simplex_dim
|
int
|
The topological dimension of the considered simplices. |
required |
face_dim
|
int
|
The topological dimension of the desired faces.
If None, the method consider |
None
|
Returns:
| Type | Description |
|---|---|
list of list of int
|
The list of face indices for all simplices in the considered k-Module. |
Notes
- The parameters must verify: 0 <= face_dim <= simplex_dim <=self.dim.
- If face_dim == simplex_dim, the list of simplex indices is returned.
- This method may seem redundant with the
closuremethod. Actualy, it is meant to be applied globally on the whole complex while theclosuremethod is restricted to small subsets of simplices. - Its design makes it much faster and therefore suitable for processing the whole structure at once, especially during instantiation.
Source code in src/dxtr/complexes/abstractsimplicialcomplex.py
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 | |
get_indices(splcs)
Gets the indices of the given simplices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
splcs
|
list of list of int
|
The list of k-simplices to get the indices of, all the simplices should have the same dimensions |
required |
Returns:
| Type | Description |
|---|---|
list of int
|
The indices of the given simplices |
Source code in src/dxtr/complexes/abstractsimplicialcomplex.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | |
incidence_matrix(top_dim, low_dim)
Computes the incidence matrix between k-simplices and l-simplices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
top_dim
|
int
|
The highest topological dimension (k) of the simplices to consider. |
required |
low_dim
|
int
|
The smallest topological dimension (l) of the simplices to consider. |
required |
Returns:
| Type | Description |
|---|---|
scipy.sparse.csr_matrix of int, optional
|
A sparse matrix of shape (Nl, Nk), filled with 0s and 1s, where Nl and Nk are respectively the numbers of l-simplices and k-simplices. |
Notes
- The (i,j)-element is 1 if the 0-simplex of index i is a l-face of the k-simplex of index j.
- If the 2 dimension are egal, the identity matrix is returned.
Source code in src/dxtr/complexes/abstractsimplicialcomplex.py
604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 | |
interior(simplices=None)
Computes the interior of a subset of simplices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
simplices
|
dict of int to list of int
|
The list of simplex indices forming the chain we want the interior of. If None, the whole ASC is considered. |
None
|
Returns:
| Type | Description |
|---|---|
dict of int to list of int
|
The keys are topological dimensions k. The values are lists of the k-simplex indices belonging to the seeked interior ensemble. |
Notes
- If no simplices are specified, the whole ASC is considered.
- The provided indices should specify a pure (sub-)complex.
- 0-simplices have no interior. In this case the output is set to None.
Source code in src/dxtr/complexes/abstractsimplicialcomplex.py
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 | |
link(simplices, dim=None)
Gets the topological sphere surrounding the given simplices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
simplices
|
dict of int to list of int or list of int or int
|
The list of simplex indices forming the chain we want the link of. |
required |
dim
|
int
|
The topological dimension of the simplices we want the link of. |
None
|
Returns:
| Type | Description |
|---|---|
dict of int to list of int
|
The keys are topological dimensions k. The values are lists of the k-simplex indices belonging to the seeked link ensemble. |
Notes
- See the
.math.topologymodule for details.
Source code in src/dxtr/complexes/abstractsimplicialcomplex.py
394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 | |
orientation(dim=None)
Returns the orientation of highest or lowest degree simplices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dim
|
int
|
The topological dimension of the simplices we want the orientation of.
Should be either |
None
|
Returns:
| Type | Description |
|---|---|
numpy.ndarray of int, optional
|
An (N,)-shape array filled with 1 and -1. |
Source code in src/dxtr/complexes/abstractsimplicialcomplex.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | |
star(simplices, dim=None)
Gets the list of all coboundaries of a given simplex.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
simplices
|
dict of int to list of int or list of int or int
|
The list of simplex indices forming the chain we want the star of. |
required |
dim
|
int
|
The topological dimension of the simplices we want the star of. |
None
|
Returns:
| Type | Description |
|---|---|
dict of int to list of int
|
The keys are topological dimensions k. The values are lists of the k-simplex indices belonging to the seeked star ensemble. |
Notes
- See the
.math.topologymodule for details.
Source code in src/dxtr/complexes/abstractsimplicialcomplex.py
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 | |
add_lower_level_simplices_to_faces(faces, smlr_splcs)
Add lower degree simplices provided as input to the complex.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
faces
|
numpy.ndarray of int
|
The array of faces to which lower degree simplices will be added. |
required |
smlr_splcs
|
list of int
|
The list of lower degree simplices to add. |
required |
Returns:
| Type | Description |
|---|---|
numpy.ndarray of int
|
The updated array of faces with lower degree simplices added. |
Source code in src/dxtr/complexes/abstractsimplicialcomplex.py
801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 | |
add_null_incidence_matrices(chain_complex, simplices)
Add null matrices on both sides of the chain complex.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chain_complex
|
list of scipy.sparse.csr_matrix of int
|
The list of incidence matrices forming the chain complex. |
required |
simplices
|
numpy.ndarray of int
|
The array of simplices in the complex. |
required |
Notes
In order to compute properly the differential operators, we need to be able
to send 0-simplices to 0 with the boundary function and the n-simplices as
well with the coboundary one.
Source code in src/dxtr/complexes/abstractsimplicialcomplex.py
917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 | |
dimension_is_specified(dim)
Checks that the parameter dim is not None.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dim
|
int
|
The dimension to check. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the dimension is specified, False otherwise. |
Source code in src/dxtr/complexes/abstractsimplicialcomplex.py
963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 | |
order_index_loop(indices, rows, cols)
Sorts a list of simplex indices forming a loop in a following order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indices
|
list of int
|
List of indices to order. |
required |
rows
|
numpy.ndarray of int
|
Rows of nonzero elements in the simplex adjacency matrix. |
required |
cols
|
numpy.ndarray of int
|
Columns of nonzero elements in the simplex adjacency matrix. |
required |
Returns:
| Type | Description |
|---|---|
list of int
|
The seeked sorted list. |
Notes
- Prior to running this function, an adjacency matrix must be computed.
- The attributes rows and cols are extracted from such a matrix:
cols, rows = adjacency.nonzero()
Source code in src/dxtr/complexes/abstractsimplicialcomplex.py
1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 | |
ordered_splx_ids_loops(indices, adjacency)
Organizes face/coface indices in following order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indices
|
list of list of int
|
All the lists of the k-simplex indices to sort. |
required |
adjacency
|
scipy.sparse.csr_matrix of int
|
The adjacency matrix of the corresponding k-simplices. |
required |
Returns:
| Type | Description |
|---|---|
list of list of int
|
Same as the input but each element is now in following order. |
Source code in src/dxtr/complexes/abstractsimplicialcomplex.py
1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 | |
remove_duplicated_simplices(faces)
Remove simplices that could have been generated twice.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
faces
|
numpy.ndarray of int
|
The array of faces from which duplicated simplices will be removed. |
required |
Returns:
| Type | Description |
|---|---|
numpy.ndarray of int
|
The updated array of faces with duplicated simplices removed. |
Source code in src/dxtr/complexes/abstractsimplicialcomplex.py
899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 | |