当前位置: 首页>>代码示例>>PHP>>正文


PHP Graph::hasVertex方法代码示例

本文整理汇总了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);
             }
         }
     }
 }
开发者ID:evispa,项目名称:object-migration,代码行数:31,代码来源:VersionPathSearch.php

示例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'));
 }
开发者ID:metabor,项目名称:statemachine,代码行数:13,代码来源:GraphBuilderTest.php

示例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;
 }
开发者ID:mhujer,项目名称:steward,代码行数:31,代码来源:ProcessSet.php

示例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);
             }
         }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:31,代码来源:sequence.ajax.php

示例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'));
 }
开发者ID:feffi,项目名称:graph,代码行数:14,代码来源:GraphTest.php


注:本文中的Fhaculty\Graph\Graph::hasVertex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。