Skip to content
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

Rename Edge classes to Edge, EdgeUndirected and EdgeDirected #178

Merged
merged 1 commit into from
Oct 5, 2019
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
12 changes: 8 additions & 4 deletions src/Edge/Base.php → src/Edge.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
<?php

namespace Graphp\Graph\Edge;
namespace Graphp\Graph;

use Graphp\Graph\Attribute\AttributeAware;
use Graphp\Graph\Attribute\AttributeBagReference;
use Graphp\Graph\Exception\BadMethodCallException;
use Graphp\Graph\Exception\InvalidArgumentException;
use Graphp\Graph\Exception\LogicException;
use Graphp\Graph\Exception\RangeException;
use Graphp\Graph\Graph;
use Graphp\Graph\Set\Vertices;
use Graphp\Graph\Set\VerticesAggregate;
use Graphp\Graph\Vertex;

abstract class Base implements VerticesAggregate, AttributeAware
/**
* Abstract base for `EdgeUndirected` and `EdgeDirected` containing common interfaces and behavior for all edges.
*
* @see EdgeUndirected
* @see EdgeDirected
*/
abstract class Edge implements VerticesAggregate, AttributeAware
{
/**
* weight of this edge
Expand Down
6 changes: 2 additions & 4 deletions src/Edge/Directed.php → src/EdgeDirected.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<?php

namespace Graphp\Graph\Edge;
namespace Graphp\Graph;

use Graphp\Graph\Exception\InvalidArgumentException;
use Graphp\Graph\Graph;
use Graphp\Graph\Set\Vertices;
use Graphp\Graph\Vertex;

class Directed extends Base
class EdgeDirected extends Edge
{
/**
* source/start vertex
Expand Down
6 changes: 2 additions & 4 deletions src/Edge/Undirected.php → src/EdgeUndirected.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<?php

namespace Graphp\Graph\Edge;
namespace Graphp\Graph;

use Graphp\Graph\Exception\InvalidArgumentException;
use Graphp\Graph\Graph;
use Graphp\Graph\Vertex;
use Graphp\Graph\Set\Vertices;

class Undirected extends Base
class EdgeUndirected extends Edge
{
/**
* vertex a
Expand Down
3 changes: 0 additions & 3 deletions src/Graph.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

use Graphp\Graph\Attribute\AttributeAware;
use Graphp\Graph\Attribute\AttributeBagReference;
use Graphp\Graph\Edge\Base as Edge;
use Graphp\Graph\Edge\Directed as EdgeDirected;
use Graphp\Graph\Edge\Undirected as EdgeUndirected;
use Graphp\Graph\Exception\BadMethodCallException;
use Graphp\Graph\Exception\InvalidArgumentException;
use Graphp\Graph\Exception\OutOfBoundsException;
Expand Down
2 changes: 1 addition & 1 deletion src/Set/Edges.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Graphp\Graph\Set;

use Graphp\Graph\Edge\Base as Edge;
use Graphp\Graph\Edge;
use Graphp\Graph\Exception\InvalidArgumentException;
use Graphp\Graph\Exception\OutOfBoundsException;
use Graphp\Graph\Exception\UnderflowException;
Expand Down
2 changes: 0 additions & 2 deletions src/Vertex.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

use Graphp\Graph\Attribute\AttributeAware;
use Graphp\Graph\Attribute\AttributeBagReference;
use Graphp\Graph\Edge\Base as Edge;
use Graphp\Graph\Edge\Directed as EdgeDirected;
use Graphp\Graph\Exception\BadMethodCallException;
use Graphp\Graph\Exception\InvalidArgumentException;
use Graphp\Graph\Set\Edges;
Expand Down
1 change: 0 additions & 1 deletion src/Walk.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Graphp\Graph\Set\Edges;
use Graphp\Graph\Set\Vertices;
use Graphp\Graph\Edge\Base as Edge;
use Graphp\Graph\Exception\UnderflowException;
use Graphp\Graph\Exception\InvalidArgumentException;
use Graphp\Graph\Set\DualAggregate;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<?php

namespace Graphp\Graph\Tests\Edge;
namespace Graphp\Graph\Tests;

use Graphp\Graph\Graph;
use Graphp\Graph\Edge\Base as Edge;
use Graphp\Graph\Tests\TestCase;
use Graphp\Graph\Edge;

class EdgeAttributesTest extends TestCase
{
/**
*
* @var Edge
*/
private $edge;
Expand Down
5 changes: 2 additions & 3 deletions tests/Edge/EdgeBaseTest.php → tests/EdgeBaseTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace Graphp\Graph\Tests\Edge;
namespace Graphp\Graph\Tests;

use Graphp\Graph\Graph;
use Graphp\Graph\Edge\Base as Edge;
use Graphp\Graph\Edge;
use Graphp\Graph\Tests\Attribute\AbstractAttributeAwareTest;

abstract class EdgeBaseTest extends AbstractAttributeAwareTest
Expand All @@ -13,7 +13,6 @@ abstract class EdgeBaseTest extends AbstractAttributeAwareTest
protected $v2;

/**
*
* @var Edge
*/
protected $edge;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Graphp\Graph\Tests\Edge;
namespace Graphp\Graph\Tests;

class EdgeDirectedTest extends EdgeBaseTest
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Graphp\Graph\Tests\Edge;
namespace Graphp\Graph\Tests;

class EdgeUndirectedTest extends EdgeBaseTest
{
Expand Down
4 changes: 2 additions & 2 deletions tests/Set/EdgesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Graphp\Graph\Tests\Set;

use Graphp\Graph\Edge\Base as Edge;
use Graphp\Graph\Edge;
use Graphp\Graph\Graph;
use Graphp\Graph\Set\Edges;
use Graphp\Graph\Tests\TestCase;
Expand Down Expand Up @@ -156,7 +156,7 @@ public function testTwoRandom(Edges $edges)
{
$edgeRandom = $edges->getEdgeOrder(Edges::ORDER_RANDOM);

$this->assertInstanceOf('Graphp\Graph\Edge\Base', $edgeRandom);
$this->assertInstanceOf('Graphp\Graph\Edge', $edgeRandom);
$edges->getEdgeIndex($edges->getIndexEdge($edgeRandom));

$edgesRandom = $edges->getEdgesOrder(Edges::ORDER_RANDOM);
Expand Down
6 changes: 3 additions & 3 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Graphp\Graph\Tests;

use Graphp\Graph\Edge\Directed;
use Graphp\Graph\Edge\Base as Edge;
use Graphp\Graph\Edge;
use Graphp\Graph\EdgeDirected;
use Graphp\Graph\Graph;
use Graphp\Graph\Vertex;
use PHPUnit\Framework\TestCase as BaseTestCase;
Expand Down Expand Up @@ -81,7 +81,7 @@ private function getVertexDump(Vertex $vertex)
private function getEdgeDump(Edge $edge)
{
$ret = get_class($edge) . ' ';
if ($edge instanceof Directed) {
if ($edge instanceof EdgeDirected) {
$ret .= $edge->getVertexStart()->getId() . ' -> ' . $edge->getVertexEnd()->getId();
} else {
$vertices = $edge->getVertices()->getIds();
Expand Down