about summary refs log tree commit diff
path: root/sourcecodes/network_layout_evd.php
diff options
context:
space:
mode:
authorziejd22018-03-14 23:19:16 -0500
committerziejd22018-03-14 23:19:16 -0500
commitc80226899f5cdd9f11c163817d59445213f5bef0 (patch)
treee0fd79d2e32fd2aedda2eadaed0f19af3514c520 /sourcecodes/network_layout_evd.php
parent324ebc8ddacab8e154047b8518afd5cbb5bb2fa4 (diff)
downloadBNW-c80226899f5cdd9f11c163817d59445213f5bef0.tar.gz
Separating Octave and php calculations
Diffstat (limited to 'sourcecodes/network_layout_evd.php')
-rw-r--r--sourcecodes/network_layout_evd.php162
1 files changed, 36 insertions, 126 deletions
diff --git a/sourcecodes/network_layout_evd.php b/sourcecodes/network_layout_evd.php
index 4efd35da..09554624 100644
--- a/sourcecodes/network_layout_evd.php
+++ b/sourcecodes/network_layout_evd.php
@@ -1,6 +1,9 @@
 <?php 
 include("structuremap.php");
 
+//This function is used to transfer between the integral
+//  levels for discrete nodes that required by BNT and
+//  the actual states of the levels that are in the input file.
 function levelmap($inx,$name,$mapdata)
 {
 
@@ -21,7 +24,8 @@ foreach($leve_l as $l)
 }
 
 
-////////////////////////////////////Read data from net_figure file///////////////////////Graphp Display/////////////////////////////////////////////
+/////////////Read data from net_figure file/////////////
+
 $dir="./data/";
 
 
@@ -44,7 +48,7 @@ $str_arrmat=explode("\n",$matrix1);
 if($str_arrmat[2]=="" || $matrix1=="")
 {
 ?>
-  <h1><font color=blue>Error: Unable to display your network structure 1.</font></h1>
+  <h1><font color=blue>Error: Unable to display your network structure.</font></h1>
 <?php
 exit;
 }
@@ -53,36 +57,10 @@ $datamat=array();
 $data_read=array();
  
 $node=trim($str_arrmat[0]);
-/*
-if($node<=5)
-{
-  $width=200;
-  $hieght=150;
-  $font=14;
-}
-else if($node>5 && $node<=7)
-{
-  $width=150;
-  $hieght=120;
-  $font=12;
 
-}
-else if($node>7 && $node<=10)
-{
-  $width=110;
-  $hieght=85;
-  $font=10;
-}
-else 
-{
-  $width=80;
-  $hieght=60;
-  $font=8;
-}
-*/
-  $width=150;
-  $hieght=150;
-  $font=12;
+$width=150;
+$height=150;
+$font=12;
 
 $r_index=$node+2;
 
@@ -93,26 +71,21 @@ $data_read[$i][0]=trim($datamat[0]);  //name
 $data_read[$i][1]=trim($datamat[1]);  //datatype
 $col_in=2;
 $r_index+=4;
-	if($datamat[1]==1)  //type=coninuous
+	if($datamat[1]==1)  //type=continuous
 	{
          for($j=1;$j<=101;$j++)
          {
            $datamat=explode("\t",$str_arrmat[$r_index]);
            $data_read[$i][$col_in]=trim($datamat[0]);  //x data
-         //  echo $data_read[$i][$col_in];
-          // echo '&nbsp';
 
            $col_in++;
            $data_read[$i][$col_in]=trim($datamat[1]);  //y data
-          // echo $data_read[$i][$col_in];
-	   // echo '&nbsp';
 
            $col_in++;
            $r_index++; // increment to point next data
-           // echo "<br />"; 
          } 
 	}
-	if($datamat[1]>1)  //type=descrete
+	if($datamat[1]>1)  //type=discrete
 	{
          $iter=$datamat[1];
          for($j=1;$j<=$iter;$j++)
@@ -120,46 +93,28 @@ $r_index+=4;
            $datamat=explode("\t",$str_arrmat[$r_index]);
            $data_read[$i][$col_in]=trim($datamat[0]);  //x data
            //use level mapping
-           $data_read[$i][$col_in]=levelmap($data_read[$i][$col_in],$data_read[$i][0],$levelmap);
+	   $data_read[$i][$col_in]=levelmap($data_read[$i][$col_in],$data_read[$i][0],$levelmap);
  
            $col_in++;
            $data_read[$i][$col_in]=trim($datamat[1]);  //y data
          
            $col_in++;
            $r_index++; // increment to point next data
-           //echo "<br />"; 
          } 
 	}
 
 }
 
 
-
-
-////////////////////////////////////////////////Graphviz data read////////////////////////////////////////////////////////////////////////////////
+/////////Graphviz data read////////////////
 
 $grv=$dir.$keyval."graphviz.txt";
 $line=shell_exec('/usr/bin/dot -Tplain -y '.$grv);
-
-
 $grviz_name_list=array();
 $g_file_name="./data/".$keyval."grviz_name_file.txt";
 $grviz_name=file_get_contents("$g_file_name");
 $grviz_name_list=explode("\n",$grviz_name);
 
-
-
-//$foutnew=fopen("contentofgraphviz.txt","w");
-//fwrite($foutnew,"$line");
-
-
-//$grfilename=$keyval."graphviz.txt";
-//$cmd="/usr/bin/dot -Tplain -y  $grfilename";
-//$line=system($cmd);
-
-
-
-
 $str_arrname=array();
 $str_arrname=explode("\n",$line);
 $data=array();
@@ -171,42 +126,29 @@ foreach($str_arrname as $row)
   $i++;
   if($i>1)
   {
-       
-  	$data=explode(" ",$row);
+       $data=explode(" ",$row);
        $j=0;
        $k=0;
        $flag=0;
   	foreach($data as $cell)
 	{
-             
              $j++;
-             
              $cell=trim($cell);
-             //echo $cell;
-             //echo '&nbsp';
              if($j==1 && $cell=="node")
              {
                 $flag=1;
              }  
-               
              if($j>1 && $j<5 && $flag==1)
              {
-    		  //echo $cell;
-   		  //echo '&nbsp';
                 if($j==2)
                 {
-                    
                    $ID_data[$ii][$k]=$grviz_name_list[$cell];
                 } 
                 else
                    $ID_data[$ii][$k]=round($cell/10*900);
-               // echo $ID_data[$ii][$k];
-                //echo '&nbsp';
-
                 $k++; 
              }
        } 
-  
        if($flag==1)
        {
           $ID_data[$ii][3]=$ID_data[$ii][1]+100;
@@ -214,10 +156,7 @@ foreach($str_arrname as $row)
           $ID_data[$ii][5]=$ID_data[$ii][1]+100;
           $ID_data[$ii][6]=$ID_data[$ii][2]; 
           $ii++;
-          //echo "<br />"; 
        } 
-     // echo "<br />"; 
-	
   }
 }
 
@@ -232,10 +171,8 @@ foreach($str_arrname as $row)
   $i++;
   if($i>1)
   {
-       
-  	$data=explode(" ",$row);
+       $data=explode(" ",$row);
        $j=0;
-       
        $flag=0;
        $number_of_point=0;
        $index=0; 
@@ -243,15 +180,12 @@ foreach($str_arrname as $row)
 	{
              $j++;
              $cell=trim($cell);
-         
              if($j==1 && $cell=="edge")
              {
                 $flag=1;
              }  
-               
              if($j==2 && $flag==1)
              {
-                
                 for($k=0;$k<$nnode;$k++)
                 {     
                       $cell=$grviz_name_list[$cell];
@@ -260,9 +194,7 @@ foreach($str_arrname as $row)
                           $edge_data[$ii][0]=$ID_data[$k][3];
                           $edge_data[$ii][1]=$ID_data[$k][4];
                       }                     
-
                 }
-               
              }
              else if($j==3 && $flag==1)
              {
@@ -273,9 +205,7 @@ foreach($str_arrname as $row)
                           $edge_data[$ii][2]=$ID_data[$k][5];
                           $edge_data[$ii][3]=$ID_data[$k][6];
                       }                     
-
                 }
-
              }
              else if($j==4 && $flag==1)
              {
@@ -286,27 +216,19 @@ foreach($str_arrname as $row)
              else if($j>4 && $number_of_point>0 && $flag==1)
              {
                 if(($j%2)!=0)
-                  $edge_data[$ii][$index]=round($cell/10*900)+60;//+30+30;
+                  $edge_data[$ii][$index]=round($cell/10*900)+60;
                 else
-                  $edge_data[$ii][$index]=round($cell/10*900)+48;//+18+30;
-
+                  $edge_data[$ii][$index]=round($cell/10*900)+48;
                 $number_of_point--;
                 $index++;
              }
-
-
-             
        } 
        if($flag==1)
        {
           $ii++;
-          //echo "<br />"; 
        } 
- 	
   }
 }
-
-
 $nedges=$ii;
 
 ?>
@@ -316,9 +238,9 @@ $nedges=$ii;
 <head>
 <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
 <script type="text/javascript" src="http://www.google.com/jsapi"></script>
- <script type="text/javascript">
-  google.load('visualization', '1', {packages: ['corechart']});
- </script>
+<script type="text/javascript">
+google.load('visualization', '1', {packages: ['corechart']});
+</script>
  
 
 <?php 
@@ -412,9 +334,9 @@ for($i=0;$i<$nnode;$i++)
         } 
          chart.draw(data,
                  {title:"<?php print($name);?>", titleTextStyle: {fontSize: <?php print($font);?>},
-                  width:<?php print($width);?>, height:<?php print($hieght);?>,
-                  vAxis: {title: "State", textStyle: {fontSize:<?php print($font);?>}},
-		    hAxis: {title: "Fraction", minValue: 0, maxValue: 1, gridlines: {count: 3}}, legend: {position: 'none'},
+                  width:<?php print($width);?>, height:<?php print($height);?>,
+                    vAxis: {textStyle: {fontSize:<?php print($font);?>}},
+		    hAxis: {minValue: 0, maxValue: 1, gridlines: {count: 3}}, legend: {position: 'none'},
                   backgroundColor: {stroke: 'black', strokeWidth: 5}}
             );
         google.visualization.events.addListener(chart, 'select', selectHandler);  
@@ -428,13 +350,13 @@ for($i=0;$i<$nnode;$i++)
   function <?php print($fname);?> {
   // Create and populate the data table.
   var data = google.visualization.arrayToDataTable([
-   ['<?php print($name);?>', ''],
+						    [{label:'<?php print($name);?>',type:'number'}, {label:''}],
   <?php
   $c_i=2;
   for($j=0;$j<100;$j++) 
   {
        $val1=trim($data_read[$s_i][$c_i]);
-       $val1=map($name,$val1,$keyval);
+       //       $val1=map($name,$val1,$keyval);
 
        $c_i++;
        $val2=trim($data_read[$s_i][$c_i]);
@@ -448,7 +370,7 @@ for($i=0;$i<$nnode;$i++)
   if($j==100)
   {
        $val1=trim($data_read[$s_i][$c_i]);
-       $val1=map($name,$val1,$keyval);
+       //       $val1=map($name,$val1,$keyval);
 
        $c_i++;
        $val2=trim($data_read[$s_i][$c_i]);
@@ -479,10 +401,11 @@ for($i=0;$i<$nnode;$i++)
             chart.draw(data, {curveType: "function",
                   title:"<?php print($name);?>", titleTextStyle: {fontSize: <?php print($font);?>},
 			legend: {position: 'none'},
-                  width:<?php print($width);?>, height:<?php print($hieght);?>,
-                  hAxis: {maxValue: 1, minValue: 0},
-			vAxis: {maxValue: 1, minValue: 0},
-                  backgroundColor: {stroke: 'black', strokeWidth: 5}}
+                  width:<?php print($width);?>, height:<?php print($height);?>,
+                  vAxis: {minValue: 0, maxValue: 1, viewWindow: {min:0}, gridlines: {count: 5}, textStyle: {fontSize: 9}},
+		    hAxis: {gridlines: {count: 4}, textStyle: {fontSize: 9},viewWindowMode: 'maximized'},
+		    chartArea:{left:30,top:25,right:8,bottom:25},
+                    backgroundColor: {stroke: 'black', strokeWidth: 5}}
             );
            google.visualization.events.addListener(chart, 'select', selectHandler); 
        }
@@ -496,9 +419,9 @@ for($i=0;$i<$nnode;$i++)
 }
 
 ///////////////////////////////////write data to file///////////////////////////////////////////////////////////
-$fl=$dir.$keyval."structure_old.txt";
-$fp = fopen("$fl","w");
-fwrite($fp,"$data_val");
+//$fl=$dir.$keyval."structure_old.txt";
+//$fp = fopen("$fl","w");
+//fwrite($fp,"$data_val");
 ?>
 
 
@@ -540,22 +463,10 @@ function canvas_arrow_draw(n, polypts,context){
 
 //Create jsGraphics object
 var headlen = 10;
-/*
-var hexno=new String;
-arr=new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f");
-var n1=Math.round(Math.random()*15);
-var n2=Math.round(Math.random()*15);
-var n3=Math.round(Math.random()*15);
-var n4=Math.round(Math.random()*15);
-var n5=Math.round(Math.random()*15);
-var n6=Math.round(Math.random()*15);
-hexno="#"+arr[n1]+""+arr[n2]+""+arr[n3]+""+arr[n4]+""+arr[n5]+""+arr[n6];
-*/
 hexno="black";
 var polypoints = new Array();
 var n2=n*2;
 
-
 var sx=polypts[0];
 var sy=polypts[1];
  
@@ -624,8 +535,7 @@ $data=$edge_data[$i][$inx];
 
 ?>
 	polypoints[j] = "<?php print($data);?>";
-
-       j++;
+        j++;
 <?php
 }
 ?>
@@ -651,7 +561,7 @@ for($i=0;$i<$nnode;$i++)
 <script type="text/javascript">
    google.setOnLoadCallback(draw_<?php print($name)?>);
 </script>
-<div id="<?php print($name)?>" style="left: <?php print($x)?>px; top: <?php print($y)?>px; width:<?php print($width);?>; height:<?php print($hieght);?>; position: absolute"></div>
+<div id="<?php print($name)?>" style="left: <?php print($x)?>px; top: <?php print($y)?>px; width:<?php print($width);?>; height:<?php print($height);?>; position: absolute"></div>
 
 <?php 
 }