-
Notifications
You must be signed in to change notification settings - Fork 3
/
order-full.php
52 lines (45 loc) · 1.12 KB
/
order-full.php
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
<?php
$noeq = $argv[1] === 'noeq';
$vals = array(
'-1' => -1,
'""' => "",
'"\\0"' => "\0",
'"1"' => "1",
'"a"' => "a",
'"b"' => "b",
'[]' => array(),
'[0]' => array(0),
'[1]' => array(1),
'[0,1]' => array(0,1),
'{}' => (object)(array()),
'{a:"b"}' => (object)(array("a"=>"b")),
'{a:"b",b:"a"}' => (object)(array("a"=>"b","b"=>"a")),
'NULL/FALSE' => FALSE,
'-INF' => -INF,
'0' => 0,
'1' => 1,
'INF' => INF,
'TRUE' => TRUE,
);
$vnames = array_keys($vals);
$vn = count($vnames);
echo "digraph G {\nconcentrate=false;\n";
for ($i=0; $i<$vn; $i++) {
echo "v$i [label=\"" . str_replace("\"","\\\"",$vnames[$i]) . "\"];\n";
}
for ($a=0; $a<$vn-1; $a++) {
$n1 = $vnames[$a];
$v1 = $vals[$n1];
for ($b=$a+1; $b<$vn; $b++) {
$n2 = $vnames[$b];
$v2 = $vals[$n2];
compare("v$a", $v1, "v$b", $v2);
}
}
echo "}\n";
function compare($n1, $v1, $n2, $v2) {
global $noeq;
if ($v1 < $v2) { echo "$n1 -> $n2;\n"; }
if ($v1 > $v2) { echo "$n2 -> $n1;\n"; }
if (!$noeq && $v1 == $v2) { echo "$n1 -> $n2 [dir=none,color=\"#009900\"];\n"; }
}