mysql — создание ориентированных графов в Stack Overflow

Я пытаюсь реализовать простой код в php, в котором я должен создать ориентированный граф из базы данных SQL. Я просто должен представить соединения E-R в виде ориентированного графа. Кто-нибудь может мне помочь?
Вот код моего новичка. Этот код еще не работает. Предложить импровизации
Этот код в основном пытается создать образец графа.

<?php
require_once 'Structures/Graph.php';`

$directedGraph =& new Structures_Graph(true);
$nonDirectedGraph =& new Structures_Graph(false);

require_once 'Structures/Graph/Node.php';

$nodeOne =& new Structures_Graph_Node();
$nodeTwo =& new Structures_Graph_Node();
$nodeThree =& new Structures_Graph_Node();
$directedGraph->addNode();
$directedGraph->addNode();
$directedGraph->addNode();

$nodeOne->connectTo($nodeTwo);
$nodeOne->connectTo($nodeThree);

$nodeOne->setData("Node One's Data is a String");
$nodeTwo->setData(1976);
$nodeThree->setData('Some other string');

print("NodeTwo's Data is an integer: " . $nodeTwo->getData());

$nodeOne->setMetadata('example key', "Node One's Sample Metadata");
print("Metadata stored under key 'example key' in node one: " . $nodeOne->getMetadata('example key'));
$nodeOne->unsetMetadata('example key');

// Nodes are able to calculate their indegree and outdegree
print("NodeOne's inDegree: " . $nodeOne->inDegree());
print("NodeOne's outDegree: " . $nodeOne->outDegree());

// and naturally, nodes can report on their arcs
$arcs = $nodeOne->getNeighbours();
for ($i=0;$i<sizeof($arcs);$i++) {
print("NodeOne has an arc to " . $arcs[$i]->getData());
}
?>
.

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector