1 2 3 4 5 6 7 8 9 10 11 12 13 14 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 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 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695
|
# Copyright (c) 1997-2024
# Ewgenij Gawrilow, Michael Joswig, and the polymake team
# Technische Universität Berlin, Germany
# https://polymake.org
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2, or (at your option) any
# later version: http://www.gnu.org/licenses/gpl.txt.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#-------------------------------------------------------------------------------
INCLUDE
morse_matching.rules
# convert Int {+1,0,-1} to Bool {true,false,undef} to capture heuristical approaches
sub ternary_to_bool($) {
my ($truth_value)=@_;
if ($truth_value>=0) { # arrived at a decision
return $truth_value;
} else {
return undef; # heuristics unsuccessful
}
}
object SimplicialComplex {
rule FACETS, VERTEX_INDICES, N_VERTICES : INPUT_FACES {
faces_to_facets($this, $this->INPUT_FACES);
}
rule FACETS : HASSE_DIAGRAM.ADJACENCY, HASSE_DIAGRAM.DECORATION, HASSE_DIAGRAM.INVERSE_RANK_MAP, HASSE_DIAGRAM.TOP_NODE, HASSE_DIAGRAM.BOTTOM_NODE {
$this->FACETS=facets_from_hasse_diagram($this->HASSE_DIAGRAM);
}
rule PURE, DIM : FACETS {
my $n=$this->FACETS->size;
my $pure=1; # let's be optimistic
my $sz=0; # simplicial complex may be empty
if ($n) {
$sz=$this->FACETS->[0]->size;
for (my $i=1; $i<$n; ++$i) {
my $s=$this->FACETS->[$i]->size();
$pure= 0 if $sz!=$s;
assign_max($sz,$s);
}
}
$this->PURE= $pure;
$this->DIM= $sz-1;
}
weight 1.10;
rule N_FACETS : FACETS {
$this->N_FACETS=$this->FACETS->size();
}
weight 0.1;
rule N_MINIMAL_NON_FACES : MINIMAL_NON_FACES {
$this->N_MINIMAL_NON_FACES=$this->MINIMAL_NON_FACES->rows();
}
weight 0.1;
rule DIM : FACETS {
$this->DIM=$this->FACETS->[0]->size()-1;
}
precondition : PURE;
weight 0.1;
rule GRAPH.ADJACENCY : FACETS {
$this->GRAPH->ADJACENCY=vertex_graph($this->FACETS);
}
weight 2.10;
rule DUAL_GRAPH.ADJACENCY : FACETS {
$this->DUAL_GRAPH->ADJACENCY=dual_graph($this->FACETS);
}
rule GRAPH.NODE_LABELS = VERTEX_LABELS;
# methods for backward compatibility
# @category Combinatorics
# Degrees of the vertices in the [[GRAPH]].
# @return Array<Int>
user_method VERTEX_DEGREES = GRAPH.NODE_DEGREES;
# @category Topology
# True if the [[GRAPH]] is a connected graph.
# @return Bool
user_method CONNECTED = GRAPH.CONNECTED;
# @category Topology
# True if the [[DUAL_GRAPH]] is a connected graph.
# @return Bool
user_method DUAL_CONNECTED = DUAL_GRAPH.CONNECTED;
# @category Combinatorics
# The connected components of the [[GRAPH]], encoded as node sets.
# @return Set<Set<Int>>
user_method CONNECTED_COMPONENTS = GRAPH.CONNECTED_COMPONENTS;
# @category Combinatorics
# The connected components of the [[DUAL_GRAPH]], encoded as node sets.
# @return Set<Set<Int>>
user_method DUAL_CONNECTED_COMPONENTS = DUAL_GRAPH.DUAL_CONNECTED_COMPONENTS;
# @category Topology
# Number of connected components of the [[GRAPH]].
# @return Int
user_method N_CONNECTED_COMPONENTS = GRAPH.N_CONNECTED_COMPONENTS;
# @category Combinatorics
# The maximal cliques of the [[GRAPH]], encoded as node sets.
# @return Set<Set<Int>>
user_method MAX_CLIQUES = GRAPH.MAX_CLIQUES;
# @category Combinatorics
# The maximal cliques of the [[DUAL_GRAPH]], encoded as node sets.
# @return Set<Set<Int>>
user_method DUAL_MAX_CLIQUES = DUAL_GRAPH.MAX_CLIQUES;
# @category Combinatorics
# Node connectivity of the [[GRAPH]], that is, the minimal number of nodes to be removed from the graph such that the result is disconnected.
# @return Int
user_method CONNECTIVITY = GRAPH.CONNECTIVITY;
# @category Combinatorics
# Node connectivity of the [[DUAL_GRAPH]]. Dual to [[CONNECTIVITY]].
# @return Set<Set<Int>>
user_method DUAL_CONNECTIVITY = DUAL_GRAPH.CONNECTIVITY;
# @category Combinatorics
# True if [[GRAPH]] is a __bipartite__.
# @return Bool
user_method BIPARTITE = GRAPH.BIPARTITE;
# @category Combinatorics
# True if [[DUAL_GRAPH]] is a __bipartite__.
# @return Bool
user_method DUAL_BIPARTITE = DUAL_GRAPH.BIPARTITE;
# @category Combinatorics
# Difference of the black and white nodes if the [[GRAPH]] is [[BIPARTITE]]. Otherwise -1.
# @return Int
user_method GRAPH_SIGNATURE = GRAPH.SIGNATURE;
# @category Combinatorics
# Difference of the black and white nodes if the [[DUAL_GRAPH]] is [[BIPARTITE]]. Otherwise -1.
# @return Int
user_method DUAL_GRAPH_SIGNATURE = DUAL_GRAPH.SIGNATURE;
rule FOLDABLE : PROJ_ORBITS, DIM {
$this->FOLDABLE = ($this->PROJ_ORBITS->size() == $this->DIM+1);
}
precondition : DUAL_GRAPH.CONNECTED;
weight 0.1;
rule F_VECTOR : FACETS, DIM, PURE {
$this->F_VECTOR=f_vector($this->FACETS,$this->DIM,$this->PURE);
}
weight 3.20;
rule H_VECTOR : F_VECTOR {
$this->H_VECTOR=h_vector($this->F_VECTOR);
}
weight 1.00;
rule SHELLING : H_VECTOR {
$this->SHELLING=shelling($this);
}
precondition : PURE;
weight 5.00;
rule SHELLABLE : SHELLING {
my @shell = @{$this->SHELLING};
my $firstface = $shell[0];
$this->SHELLABLE=@$firstface != 0;
}
precondition : PURE;
rule F_VECTOR, F2_VECTOR : HASSE_DIAGRAM.ADJACENCY, HASSE_DIAGRAM.DECORATION, HASSE_DIAGRAM.INVERSE_RANK_MAP, HASSE_DIAGRAM.TOP_NODE, HASSE_DIAGRAM.BOTTOM_NODE {
$this->F2_VECTOR=f2_vector($this->HASSE_DIAGRAM);
$this->F_VECTOR=$this->F2_VECTOR->diagonal;
}
rule EULER_CHARACTERISTIC : F_VECTOR {
my $euler_char = -1;
my $sign = 1;
my $d = $this->F_VECTOR->size();
for (my $i=0; $i<$d; ++$i) {
my $f=$this->F_VECTOR->[$i];
$euler_char += $sign*$f;
$sign = -$sign
}
$this->EULER_CHARACTERISTIC=$euler_char;
}
weight 0.40;
rule N_VERTICES : FACETS {
my $n=0;
foreach my $f (@{$this->FACETS}) {
assign_max($n, $f->[-1]+1) if @$f;
}
$this->N_VERTICES=$n;
}
weight 1.10;
rule default.homology: HOMOLOGY : FACETS {
$this->HOMOLOGY=homology($this->FACETS, 0);
}
weight 4.10;
precondition : DIM { $this->DIM>=0 }
rule default.homology: COHOMOLOGY : FACETS {
$this->COHOMOLOGY=homology($this->FACETS, 1);
}
weight 4.10;
precondition : DIM { $this->DIM>=0 }
rule default.homology: HOMOLOGY, CYCLES : FACETS {
($this->HOMOLOGY, $this->CYCLES) = homology_and_cycles($this->FACETS, 0);
}
weight 4.50;
precondition : DIM { $this->DIM>=0 }
rule default.homology: COHOMOLOGY, COCYCLES : FACETS {
($this->COHOMOLOGY, $this->COCYCLES) = homology_and_cycles($this->FACETS, 1);
}
weight 4.50;
precondition : DIM { $this->DIM>=0 }
rule INTERSECTION_FORM : CYCLES, COCYCLES {
intersection_form($this);
}
rule STIEFEL_WHITNEY : FACETS {
$this->STIEFEL_WHITNEY=stiefel_whitney($this->FACETS);
}
precondition : CLOSED_PSEUDO_MANIFOLD;
weight 5.10;
rule ODD_SUBCOMPLEX.FACETS : FACETS {
odd_complex($this);
}
precondition : PURE;
weight 3.10;
rule ODD_SUBCOMPLEX.INPUT_FACES : FACETS, BOUNDARY.FACETS, BOUNDARY.VERTEX_MAP {
odd_complex_of_manifold($this);
}
precondition : MANIFOLD;
weight 2.10;
rule SURFACE : DIM, GRAPH.CONNECTED, MANIFOLD {
$this->SURFACE= $this->GRAPH->CONNECTED && $this->MANIFOLD && $this->DIM==2;
}
weight 0.1;
rule GENUS : ORIENTED_PSEUDO_MANIFOLD, EULER_CHARACTERISTIC {
my $euler_char = $this->EULER_CHARACTERISTIC;
if ($this->ORIENTED_PSEUDO_MANIFOLD) {
$this->GENUS = (1-$euler_char)/2;
} else {
$this->GENUS = 1-$euler_char;
}
}
precondition : SURFACE;
precondition : CLOSED_PSEUDO_MANIFOLD;
weight 0.20;
rule MANIFOLD : { $this->MANIFOLD=1; }
precondition : BALL;
weight 0.1;
rule MANIFOLD : { $this->MANIFOLD=1; }
precondition : SPHERE;
weight 0.1;
# deterministic
rule MANIFOLD : FACETS, DIM, N_VERTICES {
$this->MANIFOLD=ternary_to_bool(is_manifold($this));
}
precondition : PURE;
precondition : DIM { $this->DIM < 4 }
weight 4.10;
# heuristics
rule MANIFOLD : HASSE_DIAGRAM.ADJACENCY, HASSE_DIAGRAM.DECORATION, HASSE_DIAGRAM.INVERSE_RANK_MAP, HASSE_DIAGRAM.TOP_NODE, HASSE_DIAGRAM.BOTTOM_NODE, CLOSED_PSEUDO_MANIFOLD {
$this->MANIFOLD=ternary_to_bool(is_manifold_h($this));
}
precondition : PSEUDO_MANIFOLD;
weight 4.50;
rule PSEUDO_MANIFOLD : { $this->PSEUDO_MANIFOLD=1; }
precondition : MANIFOLD;
weight 0.1;
rule PSEUDO_MANIFOLD : { $this->PSEUDO_MANIFOLD=1; }
precondition : CLOSED_PSEUDO_MANIFOLD;
weight 0.1;
rule PSEUDO_MANIFOLD : { $this->PSEUDO_MANIFOLD=1; }
precondition : ORIENTED_PSEUDO_MANIFOLD;
weight 0.1;
rule PSEUDO_MANIFOLD : HASSE_DIAGRAM.ADJACENCY, HASSE_DIAGRAM.DECORATION, HASSE_DIAGRAM.INVERSE_RANK_MAP, HASSE_DIAGRAM.TOP_NODE, HASSE_DIAGRAM.BOTTOM_NODE {
is_pseudo_manifold($this);
}
precondition : PURE;
precondition : DIM {
$this->DIM >= 1;
}
weight 1.50;
rule PSEUDO_MANIFOLD : {
$this->PSEUDO_MANIFOLD = 1;
}
precondition : DIM {
$this->DIM == 0;
}
rule MANIFOLD, PSEUDO_MANIFOLD : {
$this->MANIFOLD=0;
$this->PSEUDO_MANIFOLD=0;
}
precondition : !PURE;
weight 0.1;
rule CLOSED_PSEUDO_MANIFOLD : HASSE_DIAGRAM.ADJACENCY, HASSE_DIAGRAM.DECORATION, HASSE_DIAGRAM.INVERSE_RANK_MAP, HASSE_DIAGRAM.TOP_NODE, HASSE_DIAGRAM.BOTTOM_NODE {
is_closed_pseudo_manifold($this);
}
precondition : PURE;
precondition : DIM {
$this->DIM >= 1;
}
weight 1.50;
rule CLOSED_PSEUDO_MANIFOLD : {
$this->CLOSED_PSEUDO_MANIFOLD = 1;
}
precondition : DIM {
$this->DIM == 0;
}
weight 0.1;
rule CLOSED_PSEUDO_MANIFOLD : {
$this->CLOSED_PSEUDO_MANIFOLD=0;
}
precondition : !PURE;
weight 0.1;
rule ORIENTED_PSEUDO_MANIFOLD, ORIENTATION : FACETS, CYCLES {
my $c = $this->CYCLES;
my $faces = $c->[$c->size()-1]->faces;
my $coeff_matrix = $c->[$c->size()-1]->coeffs;
if ($coeff_matrix->rows != 1) {
$this->ORIENTED_PSEUDO_MANIFOLD = 0;
} else {
$this->ORIENTED_PSEUDO_MANIFOLD = 1;
my $iof = new Map<Set<Int>,Int>;
my $max_index=0;
foreach my $f (@{$this->FACETS}) {
$iof->{$f} = $max_index++;
}
my $row = $coeff_matrix->[0];
my $orientation = new Array<Int>($this->FACETS->size());
foreach my $face_idx (0..$faces->size()-1) {
$orientation->[$iof->{$faces->[$face_idx]}] = $row->[$face_idx];
}
$this->ORIENTATION = $orientation;
}
}
precondition : CLOSED_PSEUDO_MANIFOLD;
weight 1.00;
rule ORIENTED_PSEUDO_MANIFOLD, ORIENTATION : FACETS, N_VERTICES, BOUNDARY {
my $n = $this->N_VERTICES;
my $cc = $this->BOUNDARY->DUAL_GRAPH->CONNECTED_COMPONENTS;
# add all existing facets to a list
my @facets;
my $iof = new Map<Set<Int>,Int>;
my $max_index=0;
foreach my $f (@{$this->FACETS}) {
my $fcopy = new Set<Int>($f);
push @facets, $fcopy;
$iof->{$fcopy} = $max_index++;
}
# introduce a new cone point for each connected component of the boundary,
# and add the cones over the boundary to the list
my $boundary_vertex_map = $this->BOUNDARY->VERTEX_MAP;
my $new_verts = new Set<Int>;
foreach my $cp_number (0..$cc->rows-1) {
$new_verts += $n + $cp_number;
foreach my $dual_nodes ($cc->[$cp_number]) {
foreach my $node (@{$dual_nodes}) {
my $f = new Set<Int>(map { $boundary_vertex_map->[$_] } @{$this->BOUNDARY->FACETS->[$node]});
$f += $n + $cp_number; # add the new cone point
push @facets, $f;
}
}
}
# take a top homology cycle of this new complex, and restrict it
my $c = new SimplicialComplex(FACETS=>\@facets)->CYCLES;
my $faces = $c->[$c->size()-1]->faces;
my $coeff_matrix = $c->[$c->size()-1]->coeffs;
if ($coeff_matrix->rows != 1) {
$this->ORIENTED_PSEUDO_MANIFOLD = 0;
} else {
$this->ORIENTED_PSEUDO_MANIFOLD = 1;
my $row = $coeff_matrix->[0];
my $orientation = new Array<Int>($this->FACETS->size());
foreach my $face_idx (0..$faces->size()-1) {
if (($new_verts * $faces->[$face_idx])->size() == 0) {
$orientation->[$iof->{$faces->[$face_idx]}] = $row->[$face_idx];
}
}
$this->ORIENTATION = $orientation;
}
}
precondition : PSEUDO_MANIFOLD && !CLOSED_PSEUDO_MANIFOLD;
weight 1.50;
rule LABELED_FACETS : N_VERTICES, FACETS {
my $facets = $this->FACETS;
my $labels = new Array<String>;
if (defined (my $vertex_labels = $this->lookup("VERTEX_LABELS"))) {
$labels = $vertex_labels;
} else {
$labels = new Array<String>(map { "$_" } (0..$this->N_VERTICES-1));
}
$this->LABELED_FACETS(temporary) = labeled_output($labels, $facets, $facets->size());
}
rule LABELED_ORIENTATION : N_VERTICES, FACETS, ORIENTATION {
my $facets = $this->FACETS;
my $orientation = $this->ORIENTATION;
my $labels = new Array<String>;
if (defined (my $vertex_labels = $this->lookup("VERTEX_LABELS"))) {
$labels = $vertex_labels;
} else {
$labels = new Array<String>(map { "$_" } (0..$this->N_VERTICES-1));
}
my $max_label_length=0;
foreach my $l(@{$labels}) {
assign_max($max_label_length, length($l));
}
my @labeled_orientations;
foreach my $i (0..$orientation->size()-1) {
my $lop = "[";
my $first = 1;
foreach my $v (@{$facets->[$i]}) {
if ($first == 1) {
$first = 0;
} else {
$lop .= " " unless $max_label_length == 1;
}
$lop .= $labels->[$v];
}
$lop .= "]" . (($orientation->[$i] == 1) ? "+" : "-");
push @labeled_orientations, $lop;
}
$this->LABELED_ORIENTATION(temporary) = \@labeled_orientations;
}
rule BALL : FACETS, DIM, N_VERTICES, HASSE_DIAGRAM.ADJACENCY, HASSE_DIAGRAM.DECORATION, HASSE_DIAGRAM.INVERSE_RANK_MAP, HASSE_DIAGRAM.TOP_NODE, HASSE_DIAGRAM.BOTTOM_NODE {
$this->BALL=ternary_to_bool(is_ball_or_sphere($this,0));
}
precondition : PSEUDO_MANIFOLD;
precondition : !CLOSED_PSEUDO_MANIFOLD;
weight 4.10;
rule BALL : {
$this->BALL=0;
}
precondition : CLOSED_PSEUDO_MANIFOLD;
weight 0.1;
rule SPHERE : FACETS, DIM, N_VERTICES, HASSE_DIAGRAM.ADJACENCY, HASSE_DIAGRAM.DECORATION, HASSE_DIAGRAM.INVERSE_RANK_MAP, HASSE_DIAGRAM.TOP_NODE, HASSE_DIAGRAM.BOTTOM_NODE {
$this->SPHERE=ternary_to_bool(is_ball_or_sphere($this,1));
}
precondition : CLOSED_PSEUDO_MANIFOLD;
weight 4.10;
rule SPHERE : {
$this->SPHERE=0;
}
precondition : !CLOSED_PSEUDO_MANIFOLD;
weight 0.1;
rule HASSE_DIAGRAM.ADJACENCY, HASSE_DIAGRAM.DECORATION, HASSE_DIAGRAM.INVERSE_RANK_MAP, HASSE_DIAGRAM.TOP_NODE, HASSE_DIAGRAM.BOTTOM_NODE : FACETS {
$this->HASSE_DIAGRAM = hasse_diagram($this);
}
weight 4.10;
rule MINIMAL_NON_FACES : HASSE_DIAGRAM.ADJACENCY, HASSE_DIAGRAM.DECORATION, HASSE_DIAGRAM.INVERSE_RANK_MAP, HASSE_DIAGRAM.TOP_NODE, HASSE_DIAGRAM.BOTTOM_NODE {
$this->MINIMAL_NON_FACES=minimal_non_faces($this->HASSE_DIAGRAM);
}
weight 4.10;
precondition : DIM { $this->DIM <= 10; }
# this is not really a strict precondition for the algorithm
# it used to be implemented as a dynamic weight but those don't work as expected (#7)
# and this causes the lawler client to run for some medium sized (5-dim) examples where it
# is a lot slower than the one via the hasse-diagram
# This implements an old algorithm described by Lawler:
# "Covering problems: duality relations and a new method of solution"
# SIAM J. Appl. Math., Vol. 14, No. 5, 1966
#
# See also Chapter 2 of "Hypergraphs", C. Berge, North-Holland, Amsterdam, 1989
rule MINIMAL_NON_FACES : FACETS, DIM, N_VERTICES {
my $mnf = lawler_minimal_non_faces($this->FACETS, $this->N_VERTICES);
$this->MINIMAL_NON_FACES = new IncidenceMatrix($mnf->size > 0 ? @$mnf : 0, $this->N_VERTICES);
}
weight 4.10;
precondition : DIM { $this->DIM > 10; }
# this is not really a strict precondition for the algorithm
# it used to be implemented as a dynamic weight but those don't work as expected (#7)
# and this causes the lawler client to run for some medium sized (5-dim) examples where it
# is a lot slower than the one via the hasse-diagram
rule LOCALLY_STRONGLY_CONNECTED : {
$this->LOCALLY_STRONGLY_CONNECTED=1;
}
precondition : MANIFOLD;
weight 0.1;
rule LOCALLY_STRONGLY_CONNECTED : HASSE_DIAGRAM.ADJACENCY, HASSE_DIAGRAM.DECORATION, HASSE_DIAGRAM.INVERSE_RANK_MAP, HASSE_DIAGRAM.TOP_NODE, HASSE_DIAGRAM.BOTTOM_NODE {
$this->LOCALLY_STRONGLY_CONNECTED=is_locally_strongly_connected($this);
}
weight 2.10;
#compute boundary complex
rule BOUNDARY.FACETS, BOUNDARY.VERTEX_MAP : HASSE_DIAGRAM.ADJACENCY, HASSE_DIAGRAM.DECORATION, HASSE_DIAGRAM.INVERSE_RANK_MAP, HASSE_DIAGRAM.TOP_NODE, HASSE_DIAGRAM.BOTTOM_NODE {
($this->BOUNDARY->FACETS, $this->BOUNDARY->VERTEX_MAP) = boundary_of_pseudo_manifold($this);
}
precondition : PSEUDO_MANIFOLD;
weight 1.10;
rule VERTEX_LABELS : N_VERTICES {
my @labels = (0..$this->N_VERTICES-1);
$this->VERTEX_LABELS="@labels";
}
weight 0.10;
rule PROJ_ORBITS, PROJ_DICTIONARY : N_VERTICES, FACETS, DUAL_GRAPH.ADJACENCY {
($this->PROJ_ORBITS, $this->PROJ_DICTIONARY)=projectivities($this);
}
precondition : DUAL_GRAPH.CONNECTED;
weight 1.10;
}
# @category Topology
declare property_type Cell : c++ (include => "polymake/topaz/Filtration.h") {
# Construct a filtration cell.
# @param Int deg Filtration degree of the cell.
# @param Int dim Dimension of the cell.
# @param Int idx Row number of the cell in the boundary matrix belonging to the Filtration.
method construct(*, *, *) : c++;
operator @eq : c++;
}
# @category Topology
# A filtration of chain complexes.
# @tparam MatrixType
declare property_type Filtration<MatrixType> : c++ (include => "polymake/topaz/Filtration.h") {
# Construct a Filtration.
# @param Array<Cell> C An array containing all cells in the filtration.
# @param Array<MatrixType> bd The boundary matrices of the last frame of the filtration, indexed by dimension.
# @optional Bool s Indicates whether the cell array is already sorted by degree first and dimension second, default: false
method construct(Array<Cell>, Array<MatrixType>; $=false) : c++;
# Construct a Filtration from a HasseDiagram and an integer array.
# @param Lattice The last frame of the filtration.
# @param Array<Int> degs The degrees of the simplices in the input complex.
# Indexing after sorting them first by dimension, second lexicographically (like in the HasseDiagram)
method construct(Lattice<BasicDecoration>, Array<Int>) : c++;
operator @eq : c++;
# Returns the dimension of the maximal cells in the last frame of the filtration.
# @return Int
user_method dim() : c++;
# Returns the number of frames in of the filtration.
# @return Int
user_method n_frames() : c++;
# Returns the number of cells in the last frame of the filtration.
# @return Int
user_method n_cells() : c++;
# Returns the cells of the filtration, given as array of 3-tuples containing degree, dimension and
# boundary matrix row number of the cell.
# @return Array<Cell>
user_method cells() : c++;
# Returns the d-boundary matrix of the t-th frame of the filtration.
# @param Int d
# @param Int t
user_method boundary_matrix(Int, Int) : c++;
}
# @category Topology
# A finite chain complex, represented as its boundary matrices.
# Check out the tutorial on the polymake homepage for examples on constructing ChainComplexes and computing their homology.
#
# @example You can create a new ChainComplex by passing the Array of differential matrices (as maps via _left_ multiplication):
# > $cc = new ChainComplex(new Array<SparseMatrix<Integer>>([[[2,0]]]));
#
# Note that this creates a ChainComplex consisting three differential matrices -- the trivial zeroth and last ones
# are omitted in the constructor.
#
# You can look at the boundary matrices:
# > print $cc->boundary_matrix(1);
# | 2 0
#
# The functions ''homology'', ''homology_and_cycles'' and ''betti_numbers'' can be used to analyse your complex.
# > print homology($cc,0);
# | ({(2 1)} 1)
# | ({} 0)
# @tparam MatrixType The type of the differential matrices. default: SparseMatrix<Integer>
declare property_type ChainComplex<MatrixType = SparseMatrix<Integer>> : c++ (include => "polymake/topaz/ChainComplex.h") {
# Construct a Chain Complex.
# @param Array<MatrixType> bd The boundary matrices of the chain complex, NOT including the trivial zeroth and last matrices. Indexed by dimension. The matrices are maps via left multiplication.
# @optional Bool sanity_check Indicates whether to test if the input matrices' dimensions match and the maps satisfy the differential condition. default: 0
method construct(Array<MatrixType>; $=0) : c++;
operator @eq : c++;
# Returns the number of non-empty modules in the complex.
# @return Int
user_method dim() : c++;
# Returns the d-boundary matrix of the chain complex.
# @param Int d
# @return MatrixType
user_method boundary_matrix(*) : c++;
}
# @category Producing a new simplicial complex from others
# Computes the __barycentric subdivision__ of //complex//.
# @param SimplicialComplex complex
# @option String pin_hasse_section default: HASSE_DIAGRAM
# @option String label_section default: VERTEX_LABELS
# @option String coord_section default: VERTICES
# @option Bool geometric_realization set to 1 to obtain a [[GeometricSimplicialComplex]], default: 0
# @return SimplicialComplex (or [[GeometricSimplicialComplex]])
# @example To subdivide a triangle into six new triangles, do this:
# > $b = barycentric_subdivision(simplex(2));
user_function barycentric_subdivision($ { relabel => 1, pin_hasse_section=>"HASSE_DIAGRAM", label_section=>"VERTEX_LABELS", geometric_realization=>0, coord_section=>"VERTICES"}) {
barycentric_subdivision_impl(@_);
}
# @category Producing a new simplicial complex from others
# Computes the //k//-th __barycentric subdivision__ of //complex// by iteratively calling [[barycentric_subdivision]].
# @param SimplicialComplex complex
# @param Int k
# @option String pin_hasse_section default: HASSE_DIAGRAM
# @option String label_section default: VERTEX_LABELS
# @option String coord_section default: VERTICES
# @option Bool geometric_realization set to 1 to obtain a [[GeometricSimplicialComplex]], default: 0
# @return SimplicialComplex (or [[GeometricSimplicialComplex]])
# @example The following applies barycentric subdivision to the triangle twice.
# > $b = iterated_barycentric_subdivision(simplex(2), 2);
# > print $b -> F_VECTOR;
# | 25 60 36
user_function iterated_barycentric_subdivision(SimplicialComplex $ { relabel => 1, pin_hasse_section=>"HASSE_DIAGRAM", label_section=>"VERTEX_LABELS", geometric_realization=>0, coord_section=>"VERTICES"}) {
iterated_barycentric_subdivision_impl(@_);
}
# Local Variables:
# mode: perl
# c-basic-offset:3
# End:
|