コード例 #1
0
ファイル: SSSP.php プロジェクト: yfeng55/visualgo
 protected function init()
 {
     $this->size = rand(6, 10);
     $this->graphTemplate = GraphTemplate::getGraph(array("numVertex" => $this->size, "directed" => true, "connected" => true));
     $this->adjList = generateAdjList($this->graphTemplate);
     //array of array of Pairs
 }
コード例 #2
0
ファイル: Graph.php プロジェクト: yfeng55/visualgo
<?php

require_once 'Everything.php';
$graphParams = array();
$graphParams["numVertex"] = $_GET["numVertex"];
$graphParams["directed"] = $_GET["directed"];
if (isset($_GET["connected"])) {
    $graphParams["connected"] = $_GET["connected"] == 1 ? true : false;
}
if (isset($_GET["negativeEdge"])) {
    $graphParams["negativeEdge"] = $_GET["negativeEdge"] == 1 ? true : false;
}
if (isset($_GET["negativeCycle"])) {
    $graphParams["negativeCycle"] = $_GET["negativeCycle"] == 1 ? true : false;
}
if (isset($_GET["isDag"])) {
    $graphParams["isDag"] = $_GET["isDag"] == 1 ? true : false;
}
if (isset($_GET["directionChangeChance"])) {
    $graphParams["directionChangeChance"] = $_GET["directionChangeChance"];
}
if (isset($_GET["bidirectionChangeChance"])) {
    $graphParams["bidirectionChangeChance"] = $_GET["bidirectionChangeChance"];
}
$graph = GraphTemplate::getGraph($graphParams);
echo json_encode($graph);
コード例 #3
0
 protected function generateGraph($weighted, $directed, $connected)
 {
     $size = rand(2, 9);
     $graphTemplate = GraphTemplate::getGraph(array("numVertex" => $size, "weighted" => $weighted, "directed" => $directed, "connected" => $connected));
     return $graphTemplate;
 }