This script solves the following network:<br />
<img src="network.jpeg"><br />
<pre>
<?php
require_once('nodal.class.php');
$nodal = new Nodal();
$nodal->setnodes(4);
$nodal->refnode(0);
$nodal->connection(0, 1, 200, 0, 0, 'AB');
$nodal->connection(0, 2, 10000, 9, 0, 'AC');
$nodal->connection(0, 3, 15000, 0, 0, 'AB');
$nodal->connection(1, 2, 20, 0, 0, 'BC');
$nodal->connection(2, 3, 5000, 0, 0, 'CD');
$nodal->connection(1, 3, 1000, 0, 0, 'BD');
$table = $nodal->connectiontable();
echo "<table>";
foreach($table as $trow)
{
echo "<tr>";
foreach($trow as $element)
{
echo "<td>$element</td>";
}
echo "</tr>";
}
echo "</table>\n\nResults:";
$nodal->calculate();
print_r($nodal->results());
?>
</pre>
|