Skip to content

Update to graphp/graph #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
],
"require": {
"php": ">=5.3",
"clue/graph": "~0.9.0|~0.8.0"
"graphp/graph": "dev-master#fb198e4 as 1.0.0"
},
"require-dev": {
"phpunit/phpunit": "^6.4 || ^5.7 || ^4.8.35"
Expand Down
6 changes: 3 additions & 3 deletions src/BaseDual.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Graphp\Algorithms;

use Fhaculty\Graph\Graph;
use Fhaculty\Graph\Set\DualAggregate;
use Fhaculty\Graph\Walk;
use Graphp\Graph\Graph;
use Graphp\Graph\Set\DualAggregate;
use Graphp\Graph\Walk;

/**
* Abstract base class for algorithms that operate on a given Set instance
Expand Down
2 changes: 1 addition & 1 deletion src/BaseGraph.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Graphp\Algorithms;

use Fhaculty\Graph\Graph;
use Graphp\Graph\Graph;

/**
* Abstract base class for algorithms that operate on a given Graph instance
Expand Down
2 changes: 1 addition & 1 deletion src/BaseVertex.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Graphp\Algorithms;

use Fhaculty\Graph\Vertex;
use Graphp\Graph\Vertex;

/**
* Abstract base class for algorithms that operate on a given Vertex instance
Expand Down
4 changes: 2 additions & 2 deletions src/Bipartit.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Graphp\Algorithms;

use Fhaculty\Graph\Exception\UnexpectedValueException;
use Fhaculty\Graph\Graph;
use Graphp\Graph\Exception\UnexpectedValueException;
use Graphp\Graph\Graph;

class Bipartit extends BaseGraph
{
Expand Down
8 changes: 4 additions & 4 deletions src/ConnectedComponents.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace Graphp\Algorithms;

use Fhaculty\Graph\Exception\InvalidArgumentException;
use Fhaculty\Graph\Exception\UnderflowException;
use Fhaculty\Graph\Graph;
use Fhaculty\Graph\Vertex;
use Graphp\Algorithms\Search\BreadthFirst as SearchBreadthFirst;
use Graphp\Graph\Exception\InvalidArgumentException;
use Graphp\Graph\Exception\UnderflowException;
use Graphp\Graph\Graph;
use Graphp\Graph\Vertex;

/**
* Algorithm for working with connected components
Expand Down
6 changes: 3 additions & 3 deletions src/Degree.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Graphp\Algorithms;

use Fhaculty\Graph\Exception\UnderflowException;
use Fhaculty\Graph\Exception\UnexpectedValueException;
use Fhaculty\Graph\Vertex;
use Graphp\Graph\Exception\UnderflowException;
use Graphp\Graph\Exception\UnexpectedValueException;
use Graphp\Graph\Vertex;

/**
* Basic algorithms for working with the degrees of Graphs.
Expand Down
8 changes: 4 additions & 4 deletions src/DetectNegativeCycle.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace Graphp\Algorithms;

use Fhaculty\Graph\Exception\NegativeCycleException;
use Fhaculty\Graph\Exception\UnderflowException;
use Fhaculty\Graph\Graph;
use Fhaculty\Graph\Walk;
use Graphp\Algorithms\ShortestPath\MooreBellmanFord as SpMooreBellmanFord;
use Graphp\Graph\Exception\NegativeCycleException;
use Graphp\Graph\Exception\UnderflowException;
use Graphp\Graph\Graph;
use Graphp\Graph\Walk;

class DetectNegativeCycle extends BaseGraph
{
Expand Down
4 changes: 2 additions & 2 deletions src/Directed.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Graphp\Algorithms;

use Fhaculty\Graph\Edge\Directed as EdgeDirected;
use Fhaculty\Graph\Edge\Undirected as EdgeUndirected;
use Graphp\Graph\EdgeDirected;
use Graphp\Graph\EdgeUndirected;

/**
* Basic algorithms for working with the undirected or directed Graphs (digraphs) / Walks.
Expand Down
6 changes: 3 additions & 3 deletions src/Flow.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Graphp\Algorithms;

use Fhaculty\Graph\Edge\Directed as EdgeDirected;
use Fhaculty\Graph\Exception\UnexpectedValueException;
use Fhaculty\Graph\Vertex;
use Graphp\Graph\EdgeDirected;
use Graphp\Graph\Exception\UnexpectedValueException;
use Graphp\Graph\Vertex;

/**
* Basic algorithms for working with flow graphs
Expand Down
4 changes: 2 additions & 2 deletions src/Groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Graphp\Algorithms;

use Fhaculty\Graph\Set\Vertices;
use Fhaculty\Graph\Vertex;
use Graphp\Graph\Set\Vertices;
use Graphp\Graph\Vertex;

class Groups extends BaseGraph
{
Expand Down
2 changes: 1 addition & 1 deletion src/Loop.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Graphp\Algorithms;

use Fhaculty\Graph\Vertex;
use Graphp\Graph\Vertex;

/**
* Basic algorithms for working with loop edges
Expand Down
16 changes: 8 additions & 8 deletions src/MaxFlow/EdmondsKarp.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

namespace Graphp\Algorithms\MaxFlow;

use Fhaculty\Graph\Edge\Directed as EdgeDirected;
use Fhaculty\Graph\Exception\InvalidArgumentException;
use Fhaculty\Graph\Exception\OutOfBoundsException;
use Fhaculty\Graph\Exception\UnderflowException;
use Fhaculty\Graph\Exception\UnexpectedValueException;
use Fhaculty\Graph\Graph;
use Fhaculty\Graph\Set\Edges;
use Fhaculty\Graph\Vertex;
use Graphp\Algorithms\Base;
use Graphp\Algorithms\ResidualGraph;
use Graphp\Algorithms\ShortestPath\BreadthFirst;
use Graphp\Graph\EdgeDirected;
use Graphp\Graph\Exception\InvalidArgumentException;
use Graphp\Graph\Exception\OutOfBoundsException;
use Graphp\Graph\Exception\UnderflowException;
use Graphp\Graph\Exception\UnexpectedValueException;
use Graphp\Graph\Graph;
use Graphp\Graph\Set\Edges;
use Graphp\Graph\Vertex;

class EdmondsKarp extends Base
{
Expand Down
6 changes: 3 additions & 3 deletions src/MaximumMatching/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Graphp\Algorithms\MaximumMatching;

use Fhaculty\Graph\Exception\UnexpectedValueException;
use Fhaculty\Graph\Graph;
use Fhaculty\Graph\Set\Edges;
use Graphp\Algorithms\BaseGraph;
use Graphp\Graph\Exception\UnexpectedValueException;
use Graphp\Graph\Graph;
use Graphp\Graph\Set\Edges;

abstract class Base extends BaseGraph
{
Expand Down
12 changes: 6 additions & 6 deletions src/MaximumMatching/Flow.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace Graphp\Algorithms\MaximumMatching;

use Fhaculty\Graph\Exception\UnexpectedValueException;
use Fhaculty\Graph\Set\Edges;
use Fhaculty\Graph\Vertex;
use Graphp\Algorithms\Directed;
use Graphp\Algorithms\Groups;
use Graphp\Algorithms\MaxFlow\EdmondsKarp as MaxFlowEdmondsKarp;
use Graphp\Graph\Exception\UnexpectedValueException;
use Graphp\Graph\Set\Edges;
use Graphp\Graph\Vertex;

class Flow extends Base
{
Expand Down Expand Up @@ -42,16 +42,16 @@ public function getEdges()

if ($group === $groupA) {
// group A: source
$superSource->createEdgeTo($vertex)->setCapacity(1)->setFlow(0);
$graphFlow->createEdgeDirected($superSource, $vertex)->setCapacity(1)->setFlow(0);

// temporarily create edges from A->B for flow graph
$originalVertex = $this->graph->getVertex($vertex->getId());
foreach ($originalVertex->getVerticesEdgeTo() as $vertexTarget) {
$vertex->createEdgeTo($graphFlow->getVertex($vertexTarget->getId()))->setCapacity(1)->setFlow(0);
$graphFlow->createEdgeDirected($vertex, $graphFlow->getVertex($vertexTarget->getId()))->setCapacity(1)->setFlow(0);
}
} else {
// group B: sink
$vertex->createEdgeTo($superSink)->setCapacity(1)->setFlow(0);
$graphFlow->createEdgeDirected($vertex, $superSink)->setCapacity(1)->setFlow(0);
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/MinimumCostFlow/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
use Graphp\Algorithms\BaseGraph;
use Graphp\Algorithms\Weight as AlgorithmWeight;
use Graphp\Algorithms\Flow as AlgorithmFlow;
use Fhaculty\Graph\Exception\UnderflowException;
use Fhaculty\Graph\Exception\UnexpectedValueException;
use Fhaculty\Graph\Graph;
use Fhaculty\Graph\Set\Edges;
use Graphp\Graph\Exception\UnderflowException;
use Graphp\Graph\Exception\UnexpectedValueException;
use Graphp\Graph\Graph;
use Graphp\Graph\Set\Edges;

abstract class Base extends BaseGraph
{
Expand Down
10 changes: 5 additions & 5 deletions src/MinimumCostFlow/CycleCanceling.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace Graphp\Algorithms\MinimumCostFlow;

use Fhaculty\Graph\Exception\UnderflowException;
use Fhaculty\Graph\Exception\UnexpectedValueException;
use Fhaculty\Graph\Set\Edges;
use Graphp\Algorithms\DetectNegativeCycle;
use Graphp\Algorithms\MaxFlow\EdmondsKarp as MaxFlowEdmondsKarp;
use Graphp\Algorithms\ResidualGraph;
use Graphp\Graph\Exception\UnderflowException;
use Graphp\Graph\Exception\UnexpectedValueException;
use Graphp\Graph\Set\Edges;

class CycleCanceling extends Base
{
Expand All @@ -29,12 +29,12 @@ public function createGraph()

if ($balance > 0) {
// positive balance => source capacity
$superSource->createEdgeTo($vertex)->setCapacity($balance);
$resultGraph->createEdgeDirected($superSource, $vertex)->setCapacity($balance);

$sumBalance += $balance;
} elseif ($balance < 0) {
// negative balance => sink capacity (positive)
$vertex->createEdgeTo($superSink)->setCapacity(-$balance);
$resultGraph->createEdgeDirected($vertex, $superSink)->setCapacity(-$balance);
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/MinimumCostFlow/SuccessiveShortestPath.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace Graphp\Algorithms\MinimumCostFlow;

use Fhaculty\Graph\Edge\Directed as EdgeDirected;
use Fhaculty\Graph\Exception\UnderflowException;
use Fhaculty\Graph\Exception\UnexpectedValueException;
use Fhaculty\Graph\Graph;
use Fhaculty\Graph\Set\Edges;
use Fhaculty\Graph\Vertex;
use Graphp\Algorithms\ResidualGraph;
use Graphp\Algorithms\ShortestPath\MooreBellmanFord as SpMooreBellmanFord;
use Graphp\Algorithms\Search\BreadthFirst as SearchBreadthFirst;
use Graphp\Graph\EdgeDirected;
use Graphp\Graph\Exception\UnderflowException;
use Graphp\Graph\Exception\UnexpectedValueException;
use Graphp\Graph\Graph;
use Graphp\Graph\Set\Edges;
use Graphp\Graph\Vertex;

class SuccessiveShortestPath extends Base
{
Expand Down
6 changes: 3 additions & 3 deletions src/MinimumSpanningTree/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Graphp\Algorithms\MinimumSpanningTree;

use Fhaculty\Graph\Edge\Base as Edge;
use Fhaculty\Graph\Graph;
use Fhaculty\Graph\Set\Edges;
use Graphp\Algorithms\Base as AlgorithmBase;
use Graphp\Graph\Edge;
use Graphp\Graph\Graph;
use Graphp\Graph\Set\Edges;
use SplPriorityQueue;

/**
Expand Down
8 changes: 4 additions & 4 deletions src/MinimumSpanningTree/Kruskal.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Graphp\Algorithms\MinimumSpanningTree;

use Fhaculty\Graph\Edge\Base as Edge;
use Fhaculty\Graph\Exception\UnexpectedValueException;
use Fhaculty\Graph\Graph;
use Fhaculty\Graph\Set\Edges;
use Graphp\Graph\Edge;
use Graphp\Graph\Exception\UnexpectedValueException;
use Graphp\Graph\Graph;
use Graphp\Graph\Set\Edges;
use SplPriorityQueue;

class Kruskal extends Base
Expand Down
8 changes: 4 additions & 4 deletions src/MinimumSpanningTree/Prim.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Graphp\Algorithms\MinimumSpanningTree;

use Fhaculty\Graph\Edge\Base as Edge;
use Fhaculty\Graph\Exception\UnexpectedValueException;
use Fhaculty\Graph\Set\Edges;
use Fhaculty\Graph\Vertex;
use Graphp\Graph\Edge;
use Graphp\Graph\Exception\UnexpectedValueException;
use Graphp\Graph\Set\Edges;
use Graphp\Graph\Vertex;
use SplPriorityQueue;

class Prim extends Base
Expand Down
10 changes: 4 additions & 6 deletions src/Parallel.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

namespace Graphp\Algorithms;

use Fhaculty\Graph\Edge\Base as Edge;
use Fhaculty\Graph\Edge\Directed as DirectedEdge;
use Fhaculty\Graph\Set\Edges;
use LogicException;
use Graphp\Graph\Edge;
use Graphp\Graph\EdgeDirected as EdgeDirected;
use Graphp\Graph\Set\Edges;

/**
* Basic algorithms for working with parallel edges
Expand Down Expand Up @@ -52,11 +51,10 @@ public function hasEdgeParallelEdge(Edge $edge)
*
* @param Edge $edge
* @return Edges
* @throws LogicException
*/
public function getEdgesParallelEdge(Edge $edge)
{
if ($edge instanceof DirectedEdge) {
if ($edge instanceof EdgeDirected) {
// get all edges between this edge's endpoints
$edges = $edge->getVertexStart()->getEdgesTo($edge->getVertexEnd())->getVector();
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/Property/WalkProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Graphp\Algorithms\Property;

use Fhaculty\Graph\Walk;
use Graphp\Algorithms\Base as BaseAlgorithm;
use Graphp\Algorithms\Loop as AlgorithmLoop;
use Graphp\Graph\Walk;

/**
* Simple algorithms for working with Walk properties
Expand Down
8 changes: 4 additions & 4 deletions src/ResidualGraph.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Graphp\Algorithms;

use Fhaculty\Graph\Edge\Base as Edge;
use Fhaculty\Graph\Edge\Directed as EdgeDirected;
use Fhaculty\Graph\Exception\UnexpectedValueException;
use Fhaculty\Graph\Graph;
use Graphp\Graph\Edge;
use Graphp\Graph\EdgeDirected;
use Graphp\Graph\Exception\UnexpectedValueException;
use Graphp\Graph\Graph;

class ResidualGraph extends BaseGraph
{
Expand Down
6 changes: 3 additions & 3 deletions src/Search/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Graphp\Algorithms\Search;

use Fhaculty\Graph\Exception\InvalidArgumentException;
use Fhaculty\Graph\Set\Vertices;
use Fhaculty\Graph\Vertex;
use Graphp\Algorithms\BaseVertex;
use Graphp\Graph\Exception\InvalidArgumentException;
use Graphp\Graph\Set\Vertices;
use Graphp\Graph\Vertex;

abstract class Base extends BaseVertex
{
Expand Down
Loading