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
|
# 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.
#-------------------------------------------------------------------------------
# The aim of all these methods is to convert the obsolete properties read from a plain data file
# to the corresponding sub-object properties.
sub translate_plain_file_type : method {
(undef, my $legacy_type)=@_;
($legacy_type && eval("typeof $legacy_type"), typeof SimplicialComplex)
}
object SimplicialComplex {
# the graph and dual graph related properties
method upgrade_plain_GRAPH {
my ($this, $value)=@_;
$this->take("GRAPH.ADJACENCY", $value);
}
method upgrade_plain_DUAL_GRAPH {
my ($this, $value)=@_;
$this->take("DUAL_GRAPH.ADJACENCY", $value);
}
sub parse_graph_with_edge_attributes {
my ($value, $attr_re)=@_;
my $adjacency="";
my @map;
my $from=0;
foreach (split /\n/, $value) {
s{\(\s*(\d+)\s+($attr_re)\s*\)}{
if ($from>=$1) {
push @map, $2; $1
} else {
""
}
}eg;
$adjacency.="$_\n";
++$from;
}
return ($adjacency, \@map);
}
method upgrade_plain_MIXED_GRAPH {
my ($this, $value)=@_;
my ($adjacency, $weights)=parse_graph_with_edge_attributes($value, qr/\d+(\.\d+)?/);
$this->take("MIXED_GRAPH.ADJACENCY", $adjacency);
$this->take("MIXED_GRAPH.EDGE_WEIGHTS", $weights);
}
method upgrade_plain_VERTEX_DEGREES {
my ($this, $value)=@_;
$this->take("GRAPH.NODE_DEGREES", $value);
}
method upgrade_plain_CONNECTED {
my ($this, $value, $boolean_value)=@_;
$this->take("GRAPH.CONNECTED", $boolean_value);
}
method upgrade_plain_DUAL_CONNECTED {
my ($this, $value, $boolean_value)=@_;
$this->take("DUAL_GRAPH.CONNECTED", $boolean_value);
}
method upgrade_plain_CONNECTIVITY {
my ($this, $value, $boolean_value)=@_;
$this->take("GRAPH.CONNECTIVITY", $boolean_value);
}
method upgrade_plain_DUAL_CONNECTIVITY {
my ($this, $value, $boolean_value)=@_;
$this->take("DUAL_GRAPH.CONNECTIVITY", $boolean_value);
}
method upgrade_plain_CONNECTED_COMPONENTS {
my ($this, $value)=@_;
$this->take("GRAPH.CONNECTED_COMPONENTS", $value);
}
method upgrade_plain_DUAL_CONNECTED_COMPONENTS {
my ($this, $value)=@_;
$this->take("DUAL_GRAPH.CONNECTED_COMPONENTS", $value);
}
method upgrade_plain_N_CONNECTED_COMPONENTS {
my ($this, $value)=@_;
$this->take("GRAPH.N_CONNECTED_COMPONENTS", $value);
}
method upgrade_plain_MAX_CLIQUES {
my ($this, $value)=@_;
$this->take("GRAPH.MAX_CLIQUES", $value);
}
method upgrade_plain_DUAL_MAX_CLIQUES {
my ($this, $value)=@_;
$this->take("DUAL_GRAPH.MAX_CLIQUES", $value);
}
method upgrade_plain_BIPARTITE {
my ($this, $value, $boolean_value)=@_;
$this->take("GRAPH.BIPARTITE", $boolean_value);
}
method upgrade_plain_DUAL_BIPARTITE {
my ($this, $value, $boolean_value)=@_;
$this->take("DUAL_GRAPH.BIPARTITE", $boolean_value);
}
method upgrade_plain_GRAPH_SIGNATURE {
my ($this, $value)=@_;
$this->take("GRAPH.SIGNATURE", $value);
}
method upgrade_plain_DUAL_GRAPH_SIGNATURE {
my ($this, $value)=@_;
$this->take("DUAL_GRAPH.SIGNATURE", $value);
}
method upgrade_plain_COLORING {
my ($this, $value)=@_;
$this->take("COLORING",$value);
}
method upgrade_plain_ORIENTATION {
my ($this, $value)=@_;
my $o="";
foreach (split /\ /, $value) {
if ($_==-1) { $o.="false ";}
else {$o.="true ";}
}
$this->take("ORIENTATION", $o);
}
method upgrade_plain_DUAL_COLORING {
my ($this, $value)=@_;
$this->take("DUAL_GRAPH.COLORING", $value);
}
method upgrade_plain_HASSE_DIAGRAM {
my ($this, $value)=@_;
$this->HASSE_DIAGRAM=graph::FaceLattice_from_plain_text($value);
}
method upgrade_plain_INTERSECTION_FORM {
my ($this, $value)=@_;
$value =~ s/[()]//g;
$this->take("INTERSECTION_FORM", $value);
}
method upgrade_plain_BOUNDARY_OF_PSEUDO_MANIFOLD {
my ($this, $value)=@_;
my $res = squeeze_faces($value);
$this->take("BOUNDARY.FACETS", $res->first);
$this->take("BOUNDARY.VERTEX_MAP", $res->second);
}
method upgrade_plain_ODD_SUBCOMPLEX {
my ($this, $value)=@_;
$this->take("ODD_SUBCOMPLEX.INPUT_FACES", $value);
}
method upgrade_plain_VERTICES { } # discard
}
# Local Variables:
# mode: perl
# c-basic-offset:3
# End:
|