Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  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: 10 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( 050007), // 0
            
array( 00,10000), // 1
            
array( 080,1101), // 2
            
array( 300000), // 3
            
array( 002000), // 4
            
array( 030060)  // 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

?>