This repository was archived by the owner on Dec 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrontierZdd.php
62 lines (56 loc) · 1.76 KB
/
frontierZdd.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
53
54
55
56
57
58
59
60
61
62
<?php
require_once(__DIR__ . '/loader.php');
$g = new Graph(4);
$g->AddEdge(0, 1, 'p')->AddEdge(1, 3, 'q')->AddEdge(1, 2, 'r')->AddEdge(0, 2, 's')->AddEdge(2, 3, 't');
$zdd = new FrontierZdd($g);
$startTime = microtime(true);
$tree = $zdd->GenerateTree();
$calcTime = round((microtime(true) - $startTime), 4);
$count = 0;
echo PHP_EOL;
$tree->PrintPaths($count);
echo "Total: {$count} ways" . PHP_EOL;
echo "Calculation Time: {$calcTime} seconds" . PHP_EOL;
echo '-----' . PHP_EOL;
readline();
// Grid 4x4 vertices (3x3 edges)
$grid = Grid::Create(4);
$gridZdd = new FrontierZdd($grid);
$startTime = microtime(true);
$gridTree = $gridZdd->GenerateTree();
$calcTime = round((microtime(true) - $startTime), 4);
$count = 0;
echo PHP_EOL;
$gridTree->PrintPaths($count);
echo "Total: {$count} ways" . PHP_EOL;
echo "Calculation Time: {$calcTime} seconds" . PHP_EOL;
echo '-----' . PHP_EOL;
readline();
unset($g, $zdd, $tree, $grid, $gridZdd, $gridTree, $count);
// Grid 5x5 vertices (4x4 edges)
$grid = Grid::Create(5);
$gridZdd = new FrontierZdd($grid);
$startTime = microtime(true);
$gridTree = $gridZdd->GenerateTree();
$calcTime = round((microtime(true) - $startTime), 4);
$count = 0;
echo PHP_EOL;
$gridTree->PrintPaths($count);
echo "Total: {$count} ways" . PHP_EOL;
echo "Calculation Time: {$calcTime} seconds" . PHP_EOL;
echo '-----' . PHP_EOL;
readline();
unset($grid, $gridZdd, $gridTree, $count);
$grid = Grid::Create(6);
$gridZdd = new FrontierZdd($grid);
$startTime = microtime(true);
$gridTree = $gridZdd->GenerateTree();
$calcTime = round((microtime(true) - $startTime), 4);
$count = 0;
echo PHP_EOL;
echo 'Ready!' . PHP_EOL;
readline();
$gridTree->PrintPaths($count);
echo "Total: {$count} ways" . PHP_EOL;
echo "Calculation Time: {$calcTime} seconds" . PHP_EOL;
echo '-----' . PHP_EOL;