PHP code example of algb12 / graph-ds
1. Go to this page and download the library: Download algb12/graph-ds library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
algb12 / graph-ds example snippets
namespace GraphDS\Algo;
use GraphDS\Graph\Graph;
use GraphDS\Graph\DirectedGraph;
use GraphDS\Graph\UndirectedGraph;
use InvalidArgumentException;
// Class defining an algorithm named "Algorithm"
class Algorithm
{
// Reference to the graph
public $graph;
// Any global variables...
// Constructor accepts a GraphDS graph and validates it
public function __construct($graph)
{
if (!($graph instanceof DirectedGraph) && !($graph instanceof UndirectedGraph)) {
throw new InvalidArgumentException(
"Algorithm
$g = new DirectedGraph();