Skip to content

Commit

Permalink
Merge pull request #54 from clue/move-algo-property
Browse files Browse the repository at this point in the history
Move misc Graph/Walk property algorithms
  • Loading branch information
clue committed Jul 10, 2013
2 parents 0f3902e + 5db8930 commit 2b7db97
Show file tree
Hide file tree
Showing 7 changed files with 648 additions and 198 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ improves testablity and avoids tight coupling. Update your references if applica
| `Set::hasEdgeParallel()` | `Algorithm\Parallel::hasEdgeParallel()` | [#52](https://github.com/clue/graph/issues/52) |
| `Edge\Base::hasEdgeParallel()` | `Algorithm\Parallel::hasEdgeParallelEdge()` | [#52](https://github.com/clue/graph/issues/52) |
| `Edge\Base::getEdgesParallel()` | `Algorithm\Parallel::getEdgeParallelEdge()` | [#52](https://github.com/clue/graph/issues/52) |
|-|-|-|
| `Graph::isEdgeless()` | `Algorithm\Property\GraphProperty::isEdgeless()` | [#54](https://github.com/clue/graph/issues/54) |
| `Graph::isTrivial()` | `Algorithm\Property\GraphProperty::isTrivial()` | [#54](https://github.com/clue/graph/issues/54) |
| `Walk::isCycle()` | `Algorithm\Property\WalkProperty::isCycle()` | [#54](https://github.com/clue/graph/issues/54) |
| `Walk::isPath()` | `Algorithm\Property\WalkProperty::isPath()` | [#54](https://github.com/clue/graph/issues/54) |
| `Walk::hasCycle()` | `Algorithm\Property\WalkProperty::hasCycle()` | [#54](https://github.com/clue/graph/issues/54) |
| `Walk::isLoop()` | `Algorithm\Property\WalkProperty::isLoop()` | [#54](https://github.com/clue/graph/issues/54) |
| `Walk::isDigon()` | `Algorithm\Property\WalkProperty::isDigon()` | [#54](https://github.com/clue/graph/issues/54) |
| `Walk::isTriangle()` | `Algorithm\Property\WalkProperty::isTriangle()` | [#54](https://github.com/clue/graph/issues/54) |
| `Walk::isSimple()` | `Algorithm\Property\WalkProperty::isSimple()` | [#54](https://github.com/clue/graph/issues/54) |
| `Walk::isHamiltonian()` | `Algorithm\Property\WalkProperty::isHamiltonian()` | [#54](https://github.com/clue/graph/issues/54) |
| `Walk::isEulerian()` | `Algorithm\Property\WalkProperty::isEulerian()` | [#54](https://github.com/clue/graph/issues/54) |

* BC break: Remove unneeded algorithm alias definitions ([#31](https://github.com/clue/graph/issues/31), [#50](https://github.com/clue/graph/issues/50)). The following *alias definitions*
have been removed, their original/actual name has already existed before and continues to work
Expand Down Expand Up @@ -82,7 +94,12 @@ unchanged. Update your references if applicable:
* New `Algorithm\Tree` ([#44](https://github.com/clue/graph/issues/44))
* New `Algorithm\Loop` ([#51](https://github.com/clue/graph/issues/51))
* New `Algorithm\Parallel` ([#52](https://github.com/clue/graph/issues/52))
* New `Algorithm\Property` ([#54](https://github.com/clue/graph/issues/54))
* Feature: `Graph::createVertices()` now also accepts an array of vertex IDs ([#19](https://github.com/clue/graph/issues/19))
* Feature: Add `Algorithm\Property\WalkProperty::hasLoop()` alias definition for completeness ([#54](https://github.com/clue/graph/issues/54))
* Feature: Add `Algorithm\Property\WalkProperty::isCircuit()` definition to distinguish circuits from cycles ([#54](https://github.com/clue/graph/issues/54))
* Fix: Checking hamiltonian cycles always returned false ([#54](https://github.com/clue/graph/issues/54))
* Fix: A Walk with no edges is no longer considered a valid cycle ([#54](https://github.com/clue/graph/issues/54))
* Fix: Various issues with `Vertex`/`Edge` layout attributes ([#32](https://github.com/clue/graph/issues/32))
* Fix: Getting multiple parallel edges for undirected edges ([#52](https://github.com/clue/graph/issues/52))

Expand Down
33 changes: 33 additions & 0 deletions lib/Fhaculty/Graph/Algorithm/Property/GraphProperty.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace Fhaculty\Graph\Algorithm\Property;

use Fhaculty\Graph\Algorithm\BaseGraph;

/**
* Simple algorithms for working with Graph properties
*
* @link https://en.wikipedia.org/wiki/Graph_property
*/
class GraphProperty extends BaseGraph
{
/**
* checks whether this graph has no edges
*
* @return boolean
*/
public function isEdgeless()
{
return !$this->graph->getEdges();
}

/**
* checks whether this graph is trivial (one vertex and no edges)
*
* @return boolean
*/
public function isTrivial()
{
return (!$this->graph->getEdges() && $this->graph->getNumberOfVertices() === 1);
}
}
Loading

0 comments on commit 2b7db97

Please sign in to comment.