$collection['indices'][$b]; }); } $dot = dot($collection['list'], $toetsen); $collection['filename'] = $svg_filename = $datadir.md5($dot).'.svg'; if (!file_exists($svg_filename)) { $dot_filename = tempnam(sys_get_temp_dir(), 'her'); if (file_put_contents($dot_filename, $dot) === FALSE) error_system('unable to write .dot file'); $out = system("dot -Tsvg -o$svg_filename $dot_filename", $ret); if ($ret != 0) error_system("error $ret creating .svg from .dot: $out"); unlink($dot_filename); } $collection['max_colors'] = $nodig[$collection['list'][0]]; } unset($collection); $colors = array("#fbb4ae", "#b3cde3", "#ccebc5", "#decbe4", "#fed9a6", "#ffffcc", "#e5d8bd", "#fddaec", "#f2f2f2"); // meer dan 9 kleuren nodig: maak er een paar bij function kleur($colors, $i) { if (isset($colors[$i])) return $colors[$i]; return 'hsl('.(($i*47) % 360).',60%,80%)'; } $gradients = array(); foreach ($collections as &$collection) { $collection['solver']['scripts'] = array(); if ($collection['max_colors'] < 0) continue; $colorset = ''; foreach ($collection['list'] as $naam) { $eigen = $kleur[$naam]; // kleuren die deze toets ook kan krijgen als de rest blijft $vrij = array_fill(0, $collection['max_colors'], 1); foreach ($toetsen[$naam]['neighbors'] as $buur => $aantal) { $vrij[$kleur[$buur]] = 0; } $color = array($eigen); foreach ($vrij as $c => $ok) if ($ok && $c != $eigen) $color[] = $c; $sel = "\$('#n".$toetsen[$naam]['id']." > polygon, #n".$toetsen[$naam]['id']." > ellipse')"; if (count($color) == 1) { $colorset .= "$sel.attr('fill', '".kleur($colors, $eigen)."');\n"; } else { $gradname = 'grad'.implode('_', $color); $colorset .= "$sel.attr('fill', 'url(#$gradname)');\n"; if (!isset($gradients[$gradname])) { $grad = ''."\n"; for ($j = 0; $j < count($color); $j++) { $grad .= ''."\n"; $grad .= ''."\n"; } $grad .= ''."\n"; $gradients[$gradname] = $grad; } } } $collection['solver']['scripts'][] = $colorset; } unset($collection); // disallow freak behavior in php with foreach and & // de oplossingen meteen tonen $alles = ''; foreach ($collections as $collection) { foreach ($collection['solver']['scripts'] as $script) $alles .= $script; } html_start(<<

ST's die buiten beschouwing zijn gelaten:


ST's die gekoppeld zijn:


De roostergraaf gaat ervan uit dat elke toetsduur bij elke kleur kan worden afgenomen

Een toets met een kleurverloop kan, als de rest van de oplossing blijft zoals hij is, ook de andere kleuren in het verloop krijgen (de eerste kleur is de gekozen kleur). test node_A 100 minuten node_B 50 minuten node_C 80 minuten node_D 40 minuten node_E 150 minuten node_F ? minuten Toetsgroep\n"); if ($collection['max_colors'] < 0) { echo('Onbeslist: zoekgrens bereikt bij '.(-$collection['max_colors']).' kleuren, er zijn er minstens zoveel nodig.'); } else { ?>Oplossing: '.$i.''); } echo(', benodigd aantal kleuren '.$collection['max_colors'].'.'); } ?>