PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Protung Dragos   Graf   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example
Class: Graf
Computing routes and distances between two points
Author: By
Last change: changed the code from the class , so now there are other ways for using it.
Date: 19 years ago
Size: 1,171 bytes
 

Contents

Class file image Download
<?php


// including the class
include("graph.class.php");


// writing the graf (see graf.htm - need > IE 5) in a matrix
$m = array( // 0 1 2 3 4 5
           
array( 0, 5, 0, 0, 0, 7), // 0
           
array( 0, 0,10, 0, 0, 0), // 1
           
array( 0, 8, 0,11, 0, 1), // 2
           
array( 3, 0, 0, 0, 0, 0), // 3
           
array( 0, 0, 2, 0, 0, 0), // 4
           
array( 0, 3, 0, 0, 6, 0) // 5
          
);

echo
"<pre>";

$test1 = new graf($m); // initializing the class

$test1 -> ways_from_point(0); // calculating all ways from point 0 to any posible point
echo "Ways from point 0 to any posible point\n";
print_r($test1 -> routs); // printing ways

$test1 -> ways_from_point_to_point(0,3); // calculating all ways from point 0 to point 3
echo "\nWays from point 0 to point 3\n";
print_r($test1 -> routs); // printing ways

$test1 -> shortest_way(0,3); // calculating shortest way from point 0 to point 3
echo "\nShortest ways from point 0 to point 3\n";
print_r($test1 -> routs); // printing ways

echo "</pre>";

// Please send your suggestions, bug reports and general feedback to dragos@protung.ro

?>