Ejemplo n.º 1
0
<?php

require_once '../../../Data/Types/UnorderedNode.php';
require_once '../../../Data/Types/Edge.php';
use Falcraft\Data\Types;
echo "Falcraft\\Data\\Types\\Edge.php Test\n";
echo "---------------------------------\n\n";
echo "Instantiate Nodes -> ";
$success = true;
$testUnorderedNode1 = $testUnorderedNode2 - ($testUnorderedNode3 = 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";
} catch (\Exception $e) {
    $success = false;
}
if ($success) {
    echo "Success!\n";
} else {
    echo "Failure...\n";
}
echo "Instantiate Edge (testUnorderedNode1, testUnorderedNode2) -> ";
$success = true;
$testEdge = null;
try {
    $testEdge = new Types\Edge($testUnorderedNode1, $testUnorderedNode2);
} catch (\Exception $e) {
Ejemplo n.º 2
0
    $parentNode = new Types\UnorderedNode();
    echo $parentNode->getIdentifier() . "\n";
    echo "    \$rightNode = new Types\\UnorderedNode(): identifier = ";
    $rightNode = new Types\UnorderedNode();
    echo $rightNode->getIdentifier() . "\n";
    echo "    \$middleNode = new Types\\UnorderedNode(): identifier = ";
    $middleNode = new Types\UnorderedNode();
    echo $middleNode->getIdentifier() . "\n";
    echo "    \$leftNode = new Types\\UnorderedNode(): identifier = ";
    $leftNode = new Types\UnorderedNode();
    echo $leftNode->getIdentifier() . "\n";
    echo "    \$offsideNode = new Types\\UnorderedNode(): identifier = ";
    $offsideNode = new Types\UnorderedNode();
    echo $offsideNode->getIdentifier() . "\n";
    echo "    \$auxiliaryNode = new Types\\UnorderedNode(): identifier = ";
    $auxiliaryNode = new Types\UnorderedNode();
    echo $auxiliaryNode->getIdentifier() . "\n";
} catch (\Exception $e) {
    $success = false;
}
if ($success) {
    echo "\n    Success!\n\n";
} else {
    echo "\n    Failure...\n\n";
}
echo "Attaching parentNode As Parent (Incoming) [Reciprocate As Well] -> ";
$success = true;
try {
    $testCorrectOrderedNode->connectIncoming($parentNode);
    $parentNode->connectOutgoing($testCorrectOrderedNode);
} catch (\Exception $e) {
Ejemplo n.º 3
0
    $success = false;
}
if ($success) {
    echo "Success!\n";
} else {
    echo "Failure...\n";
}
echo "        UNSHIFT REFERENCE!\n";
$success = true;
unset($referenceNode);
$referenceNode = null;
try {
    $referenceNode = new Types\UnorderedNode();
    echo "            [preshift referenceNode id=" . $referenceNode->getIdentifier() . "]\n";
    $testVertexList->unshiftReference($referenceNode);
    $referenceNode = new Types\UnorderedNode();
    echo "            [postshift referenceNode id=" . $referenceNode->getIdentifier() . "]\n";
    echo "            Vertices: ";
    listVertices();
} catch (\Exception $e) {
    $success = false;
}
if ($success) {
    echo "Success!\n";
} else {
    echo "Failure...\n";
}
echo "\nResetting testVertexList...\n\n";
$success = true;
try {
    unset($testVertexList);
Ejemplo n.º 4
0
echo "\nGraph Construction And Integrity -- \n";
echo "    Resetting Nodes -> ";
$success = true;
$parentNode = $leftNode = $rightNode = $offsideNode = $auxiliaryNode = $complexNode = null;
try {
    $parentNode = new Types\UnorderedNode();
    echo "        parentNode identifier - " . $parentNode->getIdentifier() . "\n";
    $rightNode = new Types\UnorderedNode();
    echo "        rightNode identifier - " . $rightNode->getIdentifier() . "\n";
    $leftNode = new Types\UnorderedNode();
    echo "        leftNode identifier - " . $leftNode->getIdentifier() . "\n";
    $offsideNode = new Types\UnorderedNode();
    echo "        offsideNode identifier - " . $offsideNode->getIdentifier() . "\n";
    $auxiliaryNode = new Types\UnorderedNode();
    echo "        auxiliaryNode identifier - " . $auxiliaryNode->getIdentifier() . "\n";
    $complexNode = new Types\UnorderedNode();
    echo "        complexNode identifier - " . $complexNode->getIdentifier() . "\n";
} catch (\Exception $e) {
    $success = false;
}
if ($success) {
    echo "Success!\n";
} else {
    echo "Failure...\n";
}
echo "    Connecting parentNode to leftNode -> ";
$success = true;
try {
    $parentNode->connectOutgoing($leftNode);
    $leftNode->connectIncoming($parentNode);
} catch (\Exception $e) {
Ejemplo n.º 5
0
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);
Ejemplo n.º 6
0
 /**
  * OrderedNode Class Constructor
  * 
  * It takes two RestrictedSets, whose restrictions have to match the
  * OrderedNode restrictions (VertexInterface).  In this vertex model
  * (ordered node) incoming connections are parents, outgoing connections
  * are children, and mutual connections are siblings.
  * 
  * Children are a special matter, they're made up a VertexList.
  * A VertexList is an ordered list of Vertices (held together
  * by a double linked list of edges)  The vertexlist takes care of the
  * children's mutual connections (I know, bad coupling).  To do
  * vertexlist operations use getVertexList()
  * 
  * This initializes the restrictions member for the interface
  * VertexInterface (supported in Falcraft\Data\Types\Restrictions 1.3)
  * 
  * @param Falcraft\Data\Types\RestrictedSet $parents
  *              The initial parent vertices
  * @param array $children
  *              The initial children vertices in reference
  * @param Falcraft\Data\Types\RestrictedSet $siblings
  *              The initial sibling vertices
  * 
  * @throws TypesException\InvalidArgumentException
  *              If a given RestrictedSet has non-matching restrictions
  * 
  */
 public function __construct(RestrictedSet $parents = null, array $children = array(), RestrictedSet $siblings = null, array $options = array())
 {
     parent::__construct(null, null, null, $options);
     // Initialize restrictions, anything that is an instanceof (implements) VertexInterface)
     $this->restrictions = new Restrictions(array(Type::TYPED_OBJECT), array('Falcraft\\Data\\Types\\Resource\\VertexInterface'), array('autoload' => true));
     // Map the parameters to the AbstractVertex lingo
     $params = array('incoming' => 'parents', 'mutual' => 'siblings');
     // Cycle through parameters, replacing 'incoming' with 'parents' etc.
     // This whole mixup is done so that people won't be confused about where
     // to put parents, children, and siblings. (incoming, outgoing, mutual)
     foreach ($params as $key => $param) {
         if (is_null(${$param})) {
             $this->{$param} = RestrictedSet::build(array(), $this->restrictions, array('strict' => true));
             // Make sure the restrictions on the RestrictedSet match with our own restrictions
         } else {
             if (Restrictions::compare($this->restrictions, ${$param}->getRestrictions())) {
                 $this->{$key} = ${$param};
             } else {
                 throw new TypesException\InvalidArgumentException('OrderedNode->__construct: Improper RestrictedSet At ' . 'Constructor: ' . $param);
             }
         }
     }
     // Children are a special matter in this class
     $this->outgoing = new VertexList($children);
 }