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
|
# 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.
#-------------------------------------------------------------------------------
object SimplicialComplex {
# @category Topology
# to compute a Morse matching by the greedy algorithm
label morse_greedy
# @category Topology
# to compute a Morse matching by Forman's canceling algorithm
label morse_cancel
# @category Topology
# to compute a Morse matching by both the greedy algorithm and Forman's canceling algorithm
label morse_both
prefer morse_greedy
# @category Topology
# Morse matching in the Hasse diagram of the simplicial complex
property MORSE_MATCHING : MorseMatching : multiple {
# The matching in the HasseDiagram of the SimplicialComplex
property MATCHING : EdgeMap<Directed, Int> : construct(parent.HASSE_DIAGRAM.ADJACENCY);
};
# clients to compute Morse matching:
rule morse_greedy.morse_matching: MORSE_MATCHING(new).MATCHING : HASSE_DIAGRAM.ADJACENCY, HASSE_DIAGRAM.INVERSE_RANK_MAP, PSEUDO_MANIFOLD {
$this->MORSE_MATCHING->MATCHING = morse_matching($this, heuristic=>1, levels=> $this->PSEUDO_MANIFOLD ? 0 : 1);
}
rule morse_cancel.morse_matching: MORSE_MATCHING(new).MATCHING : HASSE_DIAGRAM.ADJACENCY, HASSE_DIAGRAM.INVERSE_RANK_MAP, PSEUDO_MANIFOLD {
$this->MORSE_MATCHING->MATCHING = morse_matching($this, heuristic=>2, levels=> $this->PSEUDO_MANIFOLD ? 0 : 1);
}
rule morse_both.morse_matching: MORSE_MATCHING(new).MATCHING : HASSE_DIAGRAM.ADJACENCY, HASSE_DIAGRAM.INVERSE_RANK_MAP, PSEUDO_MANIFOLD {
$this->MORSE_MATCHING->MATCHING = morse_matching($this, heuristic=>0, levels=> $this->PSEUDO_MANIFOLD ? 0 : 1);
}
rule morse_greedy.morse_matching: MORSE_MATCHING(any).MATCHING : HASSE_DIAGRAM.ADJACENCY, HASSE_DIAGRAM.INVERSE_RANK_MAP, PSEUDO_MANIFOLD {
$this->MORSE_MATCHING->MATCHING = morse_matching($this, heuristic=>1, levels=> $this->PSEUDO_MANIFOLD ? 0 : 1);
}
rule morse_cancel.morse_matching: MORSE_MATCHING(any).MATCHING : HASSE_DIAGRAM.ADJACENCY, HASSE_DIAGRAM.INVERSE_RANK_MAP, PSEUDO_MANIFOLD {
$this->MORSE_MATCHING->MATCHING = morse_matching($this, heuristic=>2, levels=> $this->PSEUDO_MANIFOLD ? 0 : 1);
}
rule morse_both.morse_matching: MORSE_MATCHING(any).MATCHING : HASSE_DIAGRAM.ADJACENCY, HASSE_DIAGRAM.INVERSE_RANK_MAP, PSEUDO_MANIFOLD {
$this->MORSE_MATCHING->MATCHING = morse_matching($this, heuristic=>0, levels=> $this->PSEUDO_MANIFOLD ? 0 : 1);
}
rule MORSE_MATCHING.SIZE : MORSE_MATCHING.MATCHING {
$this->MORSE_MATCHING->SIZE = morse_matching_size($this->MORSE_MATCHING);
}
rule MORSE_MATCHING.CRITICAL_FACES, MORSE_MATCHING.CRITICAL_FACE_VECTOR : HASSE_DIAGRAM.ADJACENCY, HASSE_DIAGRAM.INVERSE_RANK_MAP, MORSE_MATCHING.MATCHING {
morse_matching_critical_faces($this);
}
}
object MorseMatching {
rule N_CRITICAL_FACES : CRITICAL_FACE_VECTOR {
my $n=0;
foreach my $f (@{$this->CRITICAL_FACE_VECTOR}) {
$n += $f;
}
$this->N_CRITICAL_FACES = $n;
}
}
# Local Variables:
# mode: perl
# c-basic-offset:3
# End:
|