\Pho\Lib\GraphGraphInterface

An interface for the Graph class

Summary

Methods
Constants
id()
add()
contains()
get()
remove()
members()
count()
toArray()
loadNodesFromArray()
loadNodesFromIDArray()
canEmitNodeAddSignals()
init()
No constants found
No protected methods found
N/A
No private methods found
N/A

Methods

id()

id() : \Pho\Lib\Graph\ID

Returns the ID of the Graph

Normally the Graph object does not have an ID but it is implemented it here so that the functions that query GraphInterface objects such as SubGraphs, which do have, IDs associated, will be easier to design.

Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

\Pho\Lib\Graph\ID

The ID

add()

add(\Pho\Lib\Graph\NodeInterface  $node) : \Pho\Lib\Graph\NodeInterface

Adds a new node to the Graph.

Under normal circumstances, you don't use this function because entities are created with the graph object that they belong to in their constructor function, hence the attachment is committed automatically, including subgraphs's.

To illustare this, take a look at the following example:

$world = new Graph();
$google = new SubGraph($world);
$mark_zuckerberg = new Node($world); // facebook
$larry_page = new Node($google); // google
$vincent_cerf = new Node($google); // google
print_r($world->toArray()["members]);
print_r($google->toArray()["members]);

The output of the first print_r call, which shows $world members, will include $google members as well, even though $google members were created with the $google as their context parameter, and not $world. This is because $google was set to be a subgraph of $world in its constructor function. The link was made automatically, and this works recursively.

Parameters

\Pho\Lib\Graph\NodeInterface $node
Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

\Pho\Lib\Graph\NodeInterface

For chaining.

contains()

contains(\Pho\Lib\Graph\ID  $node_id) : boolean

Checks if the node with given ID is part of the graph.

Parameters

\Pho\Lib\Graph\ID $node_id
Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

boolean

get()

get(\Pho\Lib\Graph\ID  $node_id) : \Pho\Lib\Graph\NodeInterface

Retrieves the node with given ID

Parameters

\Pho\Lib\Graph\ID $node_id
Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

\Pho\Lib\Graph\NodeInterface

remove()

remove(\Pho\Lib\Graph\ID  $node_id) : \Pho\Lib\Graph\NodeInterface

Removes the node with given ID

Parameters

\Pho\Lib\Graph\ID $node_id
Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

\Pho\Lib\Graph\NodeInterface

members()

members() : array

Retrieves the array of members

Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

array

count()

count() : integer

Retrieves the number of graph's nodes

Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

integer

toArray()

toArray() : array

Converts the object to array

Used for serialization/unserialization. Converts internal object properties into a simple format to help with reconstruction.

Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

array —

The object in array format.

loadNodesFromArray()

loadNodesFromArray(array  $nodes) : void

Fills up the graph with members

Parameters

array $nodes

An array of NodeInterface objects.

Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

loadNodesFromIDArray()

loadNodesFromIDArray(array  $node_ids) : void

Fills up the graph with member IDs

It doesn't actually create objects. Useful for lazy-loading post-unserialization.

Parameters

array $node_ids

An array of NodeInterface IDs in string format.

Throws

\Pho\Lib\Graph\NodeAlreadyMemberException

if the node has already joined the given graph

canEmitNodeAddSignals()

canEmitNodeAddSignals() : boolean

Whether the graph should emit node addition right away.

Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

boolean

init()

init() : self

Initializer

Must be called when the object is initialized. Either manually or after deserialization.

Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

self