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


PHP Graph::createVertex方法代码示例

本文整理汇总了PHP中Fhaculty\Graph\Graph::createVertex方法的典型用法代码示例。如果您正苦于以下问题:PHP Graph::createVertex方法的具体用法?PHP Graph::createVertex怎么用?PHP Graph::createVertex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Fhaculty\Graph\Graph的用法示例。


在下文中一共展示了Graph::createVertex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testMixedParallelEdgesMultiple

 public function testMixedParallelEdgesMultiple()
 {
     // 1 -> 2
     // 1 -> 2
     // 1 -- 2
     // 1 -- 2
     // 2 -> 1
     // 2 -> 1
     $graph = new Graph();
     $v1 = $graph->createVertex(1);
     $v2 = $graph->createVertex(2);
     $e1 = $v1->createEdgeTo($v2);
     $e2 = $v1->createEdgeTo($v2);
     $e3 = $v1->createEdge($v2);
     $e4 = $v1->createEdge($v2);
     $e5 = $v2->createEdgeTo($v1);
     $e6 = $v2->createEdgeTo($v1);
     $alg = new AlgorithmParallel($graph);
     $this->assertTrue($alg->hasEdgeParallel());
     $this->assertEquals(array($e2, $e3, $e4), $alg->getEdgesParallelEdge($e1)->getVector());
     $this->assertEquals(array($e1, $e3, $e4), $alg->getEdgesParallelEdge($e2)->getVector());
     $this->assertEquals(array($e1, $e2, $e4, $e5, $e6), $alg->getEdgesParallelEdge($e3)->getVector());
     $this->assertEquals(array($e1, $e2, $e3, $e5, $e6), $alg->getEdgesParallelEdge($e4)->getVector());
     $this->assertEquals(array($e3, $e4, $e6), $alg->getEdgesParallelEdge($e5)->getVector());
     $this->assertEquals(array($e3, $e4, $e5), $alg->getEdgesParallelEdge($e6)->getVector());
 }
开发者ID:faozimipa,项目名称:algorithms,代码行数:26,代码来源:ParallelTest.php

示例2: createGraph

 /**
  *
  * @param string $dir
  * @return \Fhaculty\Graph\Graph
  */
 public function createGraph()
 {
     $graph = new Graph();
     foreach ($this->dependencyGraph->getPackages() as $package) {
         $name = $package->getName();
         $start = $graph->createVertex($name, true);
         $label = $name;
         if ($package->getVersion() !== null) {
             $label .= ': ' . $package->getVersion();
         }
         $this->setLayout($start, array('label' => $label) + $this->layoutVertex);
         foreach ($package->getOutEdges() as $requires) {
             $targetName = $requires->getDestPackage()->getName();
             $target = $graph->createVertex($targetName, true);
             $label = $requires->getVersionConstraint();
             $edge = $start->createEdgeTo($target);
             $this->setLayout($edge, array('label' => $label) + $this->layoutEdge);
             if ($requires->isDevDependency()) {
                 $this->setLayout($edge, $this->layoutEdgeDev);
             }
         }
     }
     $root = $graph->getVertex($this->dependencyGraph->getRootPackage()->getName());
     $this->setLayout($root, $this->layoutVertexRoot);
     return $graph;
 }
开发者ID:clue,项目名称:graph-composer,代码行数:31,代码来源:GraphComposer.php

示例3: testShouldOptimizeOrderBasedOnMaxSubtreeDelay

 public function testShouldOptimizeOrderBasedOnMaxSubtreeDelay()
 {
     //     -------ROOT-------
     //    / 0   / 0    \ 0   \ 0
     //   A      B      F     H
     //       3 / \ 5   | 11  | 4
     //        C   D    G     I
     //     10 |
     //        E
     // Build graph
     $graph = new Graph();
     $root = $graph->createVertex(0);
     $root->createEdgeTo($graph->createVertex('A'))->setWeight(0);
     $root->createEdgeTo($vertexB = $graph->createVertex('B'))->setWeight(0);
     $vertexB->createEdgeTo($vertexC = $graph->createVertex('C'))->setWeight(3);
     $vertexB->createEdgeTo($graph->createVertex('D'))->setWeight(5);
     $vertexC->createEdgeTo($graph->createVertex('E'))->setWeight(10);
     $root->createEdgeTo($vertexF = $graph->createVertex('F'))->setWeight(0);
     $vertexF->createEdgeTo($graph->createVertex('G'))->setWeight(11);
     $root->createEdgeTo($vertexH = $graph->createVertex('H'))->setWeight(0);
     $vertexH->createEdgeTo($graph->createVertex('I'))->setWeight(4);
     // Check the vertices have proper order value
     $strategy = new MaxTotalDelayStrategy();
     $evaluatedOrder = $strategy->optimize(new OutTree($graph));
     $this->assertSame($evaluatedOrder['A'], 0);
     $this->assertSame($evaluatedOrder['B'], 13);
     $this->assertSame($evaluatedOrder['C'], 10);
     $this->assertSame($evaluatedOrder['D'], 0);
     $this->assertSame($evaluatedOrder['E'], 0);
     $this->assertSame($evaluatedOrder['F'], 11);
     $this->assertSame($evaluatedOrder['G'], 0);
     $this->assertSame($evaluatedOrder['H'], 4);
     $this->assertSame($evaluatedOrder['I'], 0);
 }
开发者ID:mhujer,项目名称:steward,代码行数:34,代码来源:MaxTotalDelayStrategyTest.php

示例4: createGraph

 /**
  *
  * @param  string                $dir
  * @return \Fhaculty\Graph\Graph
  */
 public function createGraph($vendorName = null, $excludeDevDependency = true)
 {
     $graph = new Graph();
     foreach ($this->dependencyGraph->getPackages() as $package) {
         $name = $package->getName();
         if (null !== $vendorName && false === strpos($name, $vendorName)) {
             continue;
         }
         $start = $graph->createVertex($name, true);
         $label = $name;
         if ($package->getVersion() !== null) {
             $label .= ': ' . $package->getVersion();
         }
         $start->setLayout(array('label' => $label) + $this->getLayoutVertex($name));
         foreach ($package->getOutEdges() as $requires) {
             $targetName = $requires->getDestPackage()->getName();
             if (null !== $vendorName && false === strpos($targetName, $vendorName)) {
                 continue;
             }
             if ($excludeDevDependency && $requires->isDevDependency()) {
                 continue;
             }
             $target = $graph->createVertex($targetName, true);
             $label = $requires->getVersionConstraint();
             $start->createEdgeTo($target)->setLayout(array('label' => $label) + $this->layoutEdge);
         }
     }
     return $graph;
 }
开发者ID:tonydub,项目名称:jarvis,代码行数:34,代码来源:GraphComposer.php

示例5: testInvalidBipartit

 /**
  * expect exception for non-bipartit graphs
  * @expectedException UnexpectedValueException
  */
 public function testInvalidBipartit()
 {
     $graph = new Graph();
     $graph->createVertex(0)->setGroup(1)->createEdge($graph->createVertex(1)->setGroup(1));
     $alg = new Flow($graph);
     $alg->getNumberOfMatches();
 }
开发者ID:faozimipa,项目名称:algorithms,代码行数:11,代码来源:FlowTest.php

示例6: 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

示例7: createGraphParallelEdge

 protected function createGraphParallelEdge()
 {
     // v1 -> v2, v1 -> v2
     $graph = new Graph();
     $graph->createVertex('v1')->createEdgeTo($graph->createVertex('v2'));
     $graph->getVertex('v1')->createEdgeTo($graph->getVertex('v2'));
     return $graph;
 }
开发者ID:faozimipa,项目名称:algorithms,代码行数:8,代码来源:OutTreeTest.php

示例8: setUp

 public function setUp()
 {
     $graph = new Graph();
     $graph->createVertex(1);
     $graph->createVertex(2);
     // 1 -> 2
     $this->edge = $graph->getVertex(1)->createEdge($graph->getVertex(2));
 }
开发者ID:cmfcmf,项目名称:graph,代码行数:8,代码来源:EdgeAttributesTest.php

示例9: testFailCycle

 /**
  * @expectedException UnexpectedValueException
  */
 public function testFailCycle()
 {
     $graph = new Graph();
     $graph->createVertex(1)->createEdgeTo($graph->createVertex(2));
     $graph->getVertex(2)->createEdgeTo($graph->getVertex(1));
     $alg = new TopologicalSort($graph);
     $alg->getVertices();
 }
开发者ID:faozimipa,项目名称:algorithms,代码行数:11,代码来源:TopologicalSortTest.php

示例10: testGraphSingleUndirectedIsSymmetricr

 public function testGraphSingleUndirectedIsSymmetricr()
 {
     // 1 -- 2
     $graph = new Graph();
     $graph->createVertex(1)->createEdge($graph->createVertex(2));
     $alg = new AlgorithmSymmetric($graph);
     $this->assertTrue($alg->isSymmetric());
 }
开发者ID:faozimipa,项目名称:algorithms,代码行数:8,代码来源:SymmetricTest.php

示例11: testVertexWithUndirectedEdgeHasInvalidFlow

 /**
  * @expectedException UnexpectedValueException
  */
 public function testVertexWithUndirectedEdgeHasInvalidFlow()
 {
     // 1 -- 2
     $graph = new Graph();
     $graph->createVertex(1)->createEdge($graph->createVertex(2))->setFlow(10);
     $alg = new AlgorithmFlow($graph);
     $alg->getFlowVertex($graph->getVertex(1));
 }
开发者ID:faozimipa,项目名称:algorithms,代码行数:11,代码来源:FlowTest.php

示例12: testGraphWithUnweightedEdges

 /**
  *
  * @param Graph $graph
  * @depends testGraphSimple
  */
 public function testGraphWithUnweightedEdges(Graph $graph)
 {
     $graph->createVertex(5)->createEdgeTo($graph->createVertex(6))->setFlow(7);
     $alg = new AlgorithmWeight($graph);
     $this->assertEquals(3, $alg->getWeight());
     $this->assertEquals(12, $alg->getWeightFlow());
     $this->assertEquals(3, $alg->getWeightMin());
     $this->assertTrue($alg->isWeighted());
 }
开发者ID:feffi,项目名称:graph,代码行数:14,代码来源:WeightTest.php

示例13: testGraphMixed

 public function testGraphMixed()
 {
     // 1 -- 2 -> 3
     $graph = new Graph();
     $graph->createVertex(1)->createEdge($graph->createVertex(2));
     $graph->getVertex(2)->createEdgeTo($graph->createVertex(3));
     $alg = new AlgorithmDirected($graph);
     $this->assertTrue($alg->hasDirected());
     $this->assertTrue($alg->hasUndirected());
     $this->assertTrue($alg->isMixed());
 }
开发者ID:faozimipa,项目名称:algorithms,代码行数:11,代码来源:DirectedTest.php

示例14: drawTransitions

 /**
  * Draw all Transitions
  *
  * @return array
  */
 public function drawTransitions()
 {
     $transitions = array();
     foreach ($this->transitionsStorage as $transition) {
         $fromState = $this->graph->createVertex($transition['fromStateId'], true);
         $targetState = $this->graph->createVertex($transition['targetStateId'], true);
         $edge = $fromState->createEdgeTo($targetState)->setLayout($transition['styleAttributes']);
         $transitions[] = $edge;
     }
     return $transitions;
 }
开发者ID:cosma,项目名称:simple-state-machine,代码行数:16,代码来源:Graphic.php

示例15: testGraphParallelNegative

 /**
  * @expectedException UnexpectedValueException
  */
 public function testGraphParallelNegative()
 {
     // 1 -[10]-> 2
     // 1 -[-1]-> 2
     $graph = new Graph();
     $v1 = $graph->createVertex(1);
     $v2 = $graph->createVertex(2);
     $e1 = $v1->createEdgeTo($v2)->setWeight(10);
     $e2 = $v1->createEdgeTo($v2)->setWeight(-1);
     $alg = $this->createAlg($v1);
     $alg->getEdges();
 }
开发者ID:feffi,项目名称:graph,代码行数:15,代码来源:DijkstraTest.php


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