-
-
Notifications
You must be signed in to change notification settings - Fork 416
/
demo.php
33 lines (28 loc) · 910 Bytes
/
demo.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
<?php
// Install php, xdebug and the php debug extension for VS Code
// (https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug).
// The Debug Visualizer has no support for PHP data extractors yet,
// so to visualize data, your value must be a valid JSON string representing the data.
// See readme for supported data schemas.
$graph = [
"kind" => ["graph" => true],
"nodes" => [
["id" => "1", "label" => "1"]
],
"edges" => []
];
// Visualize "$visualize()"
$visualize = function () use (&$graph) {
return json_encode($graph);
};
for ($i = 2; $i < 100; $i++) {
// add a node
$id = "" . $i;
array_push($graph["nodes"],
["id" => $id, "label" => $id]);
// connects the node to a random edge
$targetId = "" . random_int(1, $i - 1);
array_push($graph["edges"],
["from" => $id, "to" => "" . $targetId]);
}
echo "finished";