Skip to content

Commit 0c04cd4

Browse files
committed
Move graph property algorithms to new Algorithm\Property
1 parent e57c502 commit 0c04cd4

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/Property/GraphProperty.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace Fhaculty\Graph\Algorithm\Property;
4+
5+
use Fhaculty\Graph\Algorithm\BaseGraph;
6+
7+
/**
8+
* Simple algorithms for working with Graph properties
9+
*
10+
* @link https://en.wikipedia.org/wiki/Graph_property
11+
*/
12+
class GraphProperty extends BaseGraph
13+
{
14+
/**
15+
* checks whether this graph has no edges
16+
*
17+
* @return boolean
18+
*/
19+
public function isEdgeless()
20+
{
21+
return !$this->graph->getEdges();
22+
}
23+
24+
/**
25+
* checks whether this graph is trivial (one vertex and no edges)
26+
*
27+
* @return boolean
28+
*/
29+
public function isTrivial()
30+
{
31+
return (!$this->graph->getEdges() && $this->graph->getNumberOfVertices() === 1);
32+
}
33+
}

0 commit comments

Comments
 (0)