Skip to content

Commit 550d30e

Browse files
committed
Merge branch 'master' into improve-minimumspanningtree
2 parents c595f1b + fcbdc1c commit 550d30e

6 files changed

Lines changed: 221 additions & 138 deletions

File tree

CHANGELOG.md

Lines changed: 210 additions & 130 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Looking for more example scripts? Check out [flos/graph-php](https://github.com/
4242

4343
This library is built around the concept of [mathematical graph theory](http://en.wikipedia.org/wiki/Graph_%28mathematics%29) (i.e. it is **not** a [charting](http://en.wikipedia.org/wiki/Chart) library for drawing a [graph of a function](http://en.wikipedia.org/wiki/Graph_of_a_function)). In essence, a graph is a set of *nodes* with any number of *connections* inbetween. In graph theory, [vertices](http://en.wikipedia.org/wiki/Vertex_%28graph_theory%29) (plural of vertex) are an abstract representation of these *nodes*, while *connections* are represented as *edges*. Edges may be either undirected ("two-way") or directed ("one-way", aka di-edges, arcs).
4444

45-
Depending no how the edges are constructed, the whole graph can either be undirected, can be a [directed graph](http://en.wikipedia.org/wiki/Directed_graph) (aka digraph) or be a [mixed graph](http://en.wikipedia.org/wiki/Simple_graph#Mixed_graph). Edges are also allowed to form [loops](http://en.wikipedia.org/wiki/Loop_%28graph_theory%29) (i.e. an edge from vertex A pointing to vertex A again). Also, [multiple edges](http://en.wikipedia.org/wiki/Multiple_edges) from vertex A to vertex B are supported as well (aka parallel edges), effectively forming a [multigraph](http://en.wikipedia.org/wiki/Multigraph) (aka pseudograph). And of course, any combination thereof is supported as well. While many authors try to differentiate between these core concepts, this library tries hard to not impose any artificial limitations or assumptions on your graphs.
45+
Depending on how the edges are constructed, the whole graph can either be undirected, can be a [directed graph](http://en.wikipedia.org/wiki/Directed_graph) (aka digraph) or be a [mixed graph](http://en.wikipedia.org/wiki/Simple_graph#Mixed_graph). Edges are also allowed to form [loops](http://en.wikipedia.org/wiki/Loop_%28graph_theory%29) (i.e. an edge from vertex A pointing to vertex A again). Also, [multiple edges](http://en.wikipedia.org/wiki/Multiple_edges) from vertex A to vertex B are supported as well (aka parallel edges), effectively forming a [multigraph](http://en.wikipedia.org/wiki/Multigraph) (aka pseudograph). And of course, any combination thereof is supported as well. While many authors try to differentiate between these core concepts, this library tries hard to not impose any artificial limitations or assumptions on your graphs.
4646

4747
### Graph drawing
4848

lib/Fhaculty/Graph/Algorithm/MaximumMatching/Flow.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Fhaculty\Graph\Algorithm\MaxFlow\EdmondsKarp as MaxFlowEdmondsKarp;
1212
use Fhaculty\Graph\Algorithm\Groups;
1313
use Fhaculty\Graph\Exception;
14+
use Fhaculty\Graph\Set\Edges;
1415

1516
class Flow extends Base
1617
{
@@ -81,6 +82,6 @@ public function getEdges()
8182
}
8283
}
8384

84-
return $returnEdges;
85+
return new Edges($returnEdges);
8586
}
8687
}

lib/Fhaculty/Graph/Exporter/Image.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,24 @@
88
class Image implements ExporterInterface
99
{
1010
private $format = 'png';
11-
11+
1212
public function getOutput(Graph $graph)
1313
{
1414
$graphviz = new GraphViz($graph);
1515
$graphviz->setFormat($this->format);
1616
return $graphviz->createImageData();
1717
}
18-
18+
1919
/**
2020
* set the image output format to use
21-
*
21+
*
2222
* @param string $type png, svg
2323
* @return self $this (chainable)
2424
* @see GraphViz::setFormat()
2525
*/
2626
public function setFormat($type)
2727
{
28-
$this->type = $type;
28+
$this->format = $type;
2929
return $this;
3030
}
3131
}

lib/Fhaculty/Graph/GraphViz.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,12 @@ public function display()
135135
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
136136
echo "ausgabe\n";
137137
exec($tmp . ' >NUL');
138+
} elseif (strtoupper(PHP_OS) === 'DARWIN') {
139+
// open image in background (redirect stdout to /dev/null, sterr to stdout and run in background)
140+
exec('open ' . escapeshellarg($tmp) . ' > /dev/null 2>&1 &');
138141
} else {
139142
// open image in background (redirect stdout to /dev/null, sterr to stdout and run in background)
140143
exec('xdg-open ' . escapeshellarg($tmp) . ' > /dev/null 2>&1 &');
141-
142144
}
143145

144146
$next = microtime(true) + self::DELAY_OPEN;

tests/Fhaculty/Graph/Algorithm/MaximumMatching/FlowTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function testSingleEdge()
3030
// correct number of edges
3131
$this->assertEquals(1, $alg->getNumberOfMatches());
3232
// actual edge instance returned
33-
$this->assertEquals(array($edge), $alg->getEdges());
33+
$this->assertEquals(array($edge), $alg->getEdges()->getVector());
3434

3535
// check
3636
$flowgraph = $alg->createGraph();

0 commit comments

Comments
 (0)