PHP Classes

File: Falcraft/examples/Data/Types/OrderedEdge.php

Recommend this page to a friend!
  Classes of Asher Wolfstein   Abstract Data Types   Falcraft/examples/Data/Types/OrderedEdge.php   Download  
File: Falcraft/examples/Data/Types/OrderedEdge.php
Role: Example script
Content type: text/plain
Description: Placed Edge (Graphs) Example
Class: Abstract Data Types
Set of abstract data types as pure PHP classes
Author: By
Last change:
Date: 8 years ago
Size: 2,328 bytes
 

Contents

Class file image Download
<?php

require_once('../../../Data/Types/UnorderedNode.php');
require_once(
'../../../Data/Types/Edge.php');
require_once(
'../../../Data/Types/OrderedEdge.php');

use
Falcraft\Data\Types;

echo
"Falcraft\\Data\\Types\\OrderedEdge.php Test\n";
echo
"----------------------------------------\n\n";

echo
"Instantiate UnorderedNodes -> \n";

$success = true;

$testUnorderedNode1 = $testUnorderedNode2 = $testUnorderedNode3 = $testUnorderedNode4 = null;

try {
   
$testUnorderedNode1 = new Types\UnorderedNode();
    echo
" testUnorderedNode1 identifier - " . $testUnorderedNode1->getIdentifier() . "\n";
   
   
$testUnorderedNode2 = new Types\UnorderedNode();
    echo
" testUnorderedNode2 identifier - " . $testUnorderedNode2->getIdentifier() . "\n";
   
   
$testUnorderedNode3 = new Types\UnorderedNode();
    echo
" testUnorderedNode3 identifier - " . $testUnorderedNode3->getIdentifier() . "\n";
   
   
$testUnorderedNode4 = new Types\UnorderedNode();
    echo
" testUnorderedNode4 identifier - " . $testUnorderedNode4->getIdentifier() . "\n";
} catch (\
Exception $e) {
   
$success = false;
}

if (
$success) {
    echo
"Success!\n";
} else {
    echo
"Failure...\n";
}

echo
"Instantiate Ordered Edges -> ";

$success = true;

$testOrderedEdge1 = $testOrderedEdge2 = null;

try {
   
$testOrderedEdge1 = new Types\OrderedEdge($testUnorderedNode1, $testUnorderedNode2);
   
$testOrderedEdge2 = new Types\OrderedEdge($testUnorderedNode3, $testUnorderedNode4);
} catch (\
Exception $e) {
   
$success = false;
}

if (
$success) {
    echo
"Success!\n";
} else {
    echo
"Failure...\n";
}

echo
"Linking Ordered Edges -> ";

$success = true;

try {
   
Types\OrderedEdge::connect($testOrderedEdge1, $testOrderedEdge2);
} catch (\
Exception $e) {
   
$success = false;
}

if (
$success) {
    echo
"Success!\n\n";
    echo
"Test Results\n\n";
    echo
"testOrderedEdge1 Next (Prev Node, Next Node) -> ";
    echo
"(" . $testOrderedEdge1->getNextEdge()->getPrevious()->getIdentifier() .
        
", " . $testOrderedEdge1->getNextEdge()->getNext()->getIdentifier() . ")\n";
    echo
"testOrderedEdge2 Previous (Prev Node, Next Node) -> ";
    echo
"(" . $testOrderedEdge2->getPreviousEdge()->getPrevious()->getIdentifier() .
        
", " . $testOrderedEdge2->getPreviousEdge()->getNext()->getIdentifier() . ")\n";
}