日期:2011-12-12  浏览次数:20675 次

  1. <?php 
  2.     require 'mGraph.php'
  3.     $a = array('a''b''c''d''e''f''g''h''i'); 
  4.     $b = array('ab'=>'10''af'=>'11''bg'=>'16''fg'=>'17''bc'=>'18''bi'=>'12''ci'=>'8''cd'=>'22''di'=>'21''dg'=>'24''gh'=>'19''dh'=>'16''de'=>'20''eh'=>'7','fe'=>'26');//键为边,值权值 
  5.       
  6.     $test = new MGraph($a$b); 
  7.     print_r($test->prim()); 
  8. ?> 
  9. //mGraph.php 
  10. <?php 
  11.     class MGraph{ 
  12.         private $vexs//顶点数组 
  13.         private $arc//边邻接矩阵,即二维数组        
  14.         private $a