graphp / graph

GraPHP is the mathematical graph/network library written in PHP.
MIT License
694 stars 74 forks source link

Remove `Vertices` and `Edges` collection classes, use plain arrays instead #195

Closed clue closed 4 years ago

clue commented 4 years ago

This changeset removes the Vertices and Edges collection classes and changes the code to use plain arrays instead. These collection classes (incorrectly named "sets") added some very significant complexity to the code base and bring little value for this package. Some of their methods were specifically designed for specific algorithms, so we'll port these over to graphp/algorithms as appropriate (#119).

// old
$vertices = $edge->getVertices()->getVector();
$edges = $vertex->getEdges()->getVector();
$vertex = $edge->getVertices()->getVertexFirst();
$edge = $vertex->getEdges()->getEdgeFirst();

// new
$vertices = $edge->getVertices();
$edges = $vertex->getEdges();
$vertex = \reset($vertices);
$edge = \reset($edges);

Builds on top of #188, #185 and others.