Skip to content

Commit af1d244

Browse files
committed
Move Graph::hasEdgeParallel() to new Algorithm\Parallel
1 parent 2f21d8c commit af1d244

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/Parallel.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
namespace Fhaculty\Graph\Algorithm;
4+
5+
use Fhaculty\Graph\Algorithm\BaseGraph;
6+
use Fhaculty\Graph\Edge\Base as Edge;
7+
use Fhaculty\Graph\Graph;
8+
9+
/**
10+
* Basic algorithms for working with parallel edges
11+
*
12+
* Parallel edges (also called multiple edges or a multi-edge), are two or more
13+
* edges that are incident to the same two vertices. A simple graph has no
14+
* multiple edges.
15+
*
16+
* @link http://en.wikipedia.org/wiki/Multiple_edges
17+
*/
18+
class Parallel extends BaseGraph
19+
{
20+
/**
21+
* checks whether this graph has any parallel edges (aka multigraph)
22+
*
23+
* @return boolean
24+
* @uses Edge::hasEdgeParallel() for every edge
25+
*/
26+
public function hasEdgeParallel()
27+
{
28+
foreach ($this->graph->getEdges() as $edge) {
29+
if ($edge->hasEdgeParallel()) {
30+
return true;
31+
}
32+
}
33+
34+
return false;
35+
}
36+
}

0 commit comments

Comments
 (0)