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
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.