本文整理汇总了PHP中Fhaculty\Graph\Graph::hasVertex方法的典型用法代码示例。如果您正苦于以下问题:PHP Graph::hasVertex方法的具体用法?PHP Graph::hasVertex怎么用?PHP Graph::hasVertex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fhaculty\Graph\Graph
的用法示例。
在下文中一共展示了Graph::hasVertex方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createEdges
/**
* Create edges between versions graph
*
* @param Graph $graph
* @param string $className
*/
private function createEdges(Graph $graph, $className)
{
$migrationsAnnotations = $this->reader->getClassMigrationMethodInfo($className);
$parentVertex = $graph->hasVertex($className) ? $graph->getVertex($className) : $graph->createVertex($className);
foreach ($migrationsAnnotations as $migrationsAnnotation) {
if ($migrationsAnnotation->annotation->from) {
$fromClass = $migrationsAnnotation->annotation->from;
$fromVertex = $graph->hasVertex($fromClass) ? $graph->getVertex($fromClass) : $graph->createVertex($fromClass);
if (!$parentVertex->hasEdgeTo($fromVertex)) {
$edge = $fromVertex->createEdgeTo($parentVertex);
$this->annotations[$this->getEdgeId($edge)] = $migrationsAnnotation;
$this->createEdges($graph, $fromClass);
}
}
if ($migrationsAnnotation->annotation->to) {
$toClass = $migrationsAnnotation->annotation->to;
$fromVertex = $graph->hasVertex($toClass) ? $graph->getVertex($toClass) : $graph->createVertex($toClass);
if (!$parentVertex->hasEdgeTo($fromVertex)) {
$edge = $parentVertex->createEdgeTo($fromVertex);
$this->annotations[$this->getEdgeId($edge)] = $migrationsAnnotation;
$this->createEdges($graph, $toClass);
}
}
}
}
示例2: testAddsStatesToGraph
public function testAddsStatesToGraph()
{
$state = new State('first');
$stateCollection = new StateCollection();
$stateCollection->addState($state);
$secondState = new State('second');
$state->addTransition(new Transition($secondState));
$graph = new Graph();
$builder = new GraphBuilder($graph);
$builder->addStateCollection($stateCollection);
$this->assertTrue($graph->hasVertex('first'));
$this->assertTrue($graph->hasVertex('second'));
}
示例3: buildTree
/**
* Build out-tree graph from defined Processes and their relations.
*
* @return OutTree
*/
public function buildTree()
{
if (!$this->tree) {
$root = $this->graph->createVertex(0);
// Create edges directed from the root node
foreach ($this->processes as $processClassName => $processObject) {
$vertex = $this->graph->getVertex($processClassName);
if (!$processObject->delayMinutes) {
// process doesn't depend on anything => link it to the root node
$root->createEdgeTo($vertex)->setWeight(0);
} else {
// link process to its dependency
// Throw error if dependency is to not existing vertex
if (!$this->graph->hasVertex($processObject->delayAfter)) {
throw new \InvalidArgumentException(sprintf('Testcase "%s" has @delayAfter dependency on "%s", but this testcase was not defined.', $processClassName, $processObject->delayAfter));
}
$this->graph->getVertex($processObject->delayAfter)->createEdgeTo($vertex)->setWeight($processObject->delayMinutes);
}
}
}
$this->tree = new OutTree($this->graph);
if (!$this->tree->isTree()) {
throw new \InvalidArgumentException(sprintf('Cannot build tree graph from tests dependencies. Probably some cyclic dependency is present.'));
}
return $this->tree;
}
示例4: explode
exit;
}
$parents = str_replace($id, '', $parents);
$parents = explode(',', $parents);
$parents = array_filter($parents);
if ($sequence->hasGraph()) {
$graph = $sequence->getUnSerializeGraph();
} else {
$graph = new Graph();
}
switch ($type) {
case 'session':
$type = SequenceResource::SESSION_TYPE;
$sessionInfo = api_get_session_info($id);
$name = $sessionInfo['name'];
if ($graph->hasVertex($id)) {
$main = $graph->getVertex($id);
} else {
$main = $graph->createVertex($id);
}
foreach ($parents as $parentId) {
if ($graph->hasVertex($parentId)) {
$parent = $graph->getVertex($parentId);
if (!$parent->hasEdgeTo($main)) {
$parent->createEdgeTo($main);
}
} else {
$parent = $graph->createVertex($parentId);
$parent->createEdgeTo($main);
}
}
示例5: testHasVertex
public function testHasVertex()
{
$graph = new Graph();
$graph->createVertex(1);
$graph->createVertex('string');
// check integer IDs
$this->assertFalse($graph->hasVertex(2));
$this->assertTrue($graph->hasVertex(1));
// check string IDs
$this->assertFalse($graph->hasVertex('non-existant'));
$this->assertTrue($graph->hasVertex('string'));
// integer IDs can also be checked as string IDs
$this->assertTrue($graph->hasVertex('1'));
}