From c80226899f5cdd9f11c163817d59445213f5bef0 Mon Sep 17 00:00:00 2001 From: ziejd2 Date: Wed, 14 Mar 2018 23:19:16 -0500 Subject: Separating Octave and php calculations --- sourcecodes/network_layout_evd.php | 162 +++++++++---------------------------- 1 file changed, 36 insertions(+), 126 deletions(-) (limited to 'sourcecodes/network_layout_evd.php') 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 @@ -

Error: Unable to display your network structure 1.

+

Error: Unable to display your network structure.

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 ' '; $col_in++; $data_read[$i][$col_in]=trim($datamat[1]); //y data - // echo $data_read[$i][$col_in]; - // echo ' '; $col_in++; $r_index++; // increment to point next data - // echo "
"; } } - 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 "
"; } } } - - -////////////////////////////////////////////////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 ' '; if($j==1 && $cell=="node") { $flag=1; } - if($j>1 && $j<5 && $flag==1) { - //echo $cell; - //echo ' '; 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 ' '; - $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 "
"; } - // echo "
"; - } } @@ -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 "
"; } - } } - - $nedges=$ii; ?> @@ -316,9 +238,9 @@ $nedges=$ii; - + ", titleTextStyle: {fontSize: }, - width:, height:, - vAxis: {title: "State", textStyle: {fontSize:}}, - hAxis: {title: "Fraction", minValue: 0, maxValue: 1, gridlines: {count: 3}}, legend: {position: 'none'}, + width:, height:, + vAxis: {textStyle: {fontSize:}}, + 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 { // Create and populate the data table. var data = google.visualization.arrayToDataTable([ - ['', ''], + [{label:'',type:'number'}, {label:''}], ", titleTextStyle: {fontSize: }, legend: {position: 'none'}, - width:, height:, - hAxis: {maxValue: 1, minValue: 0}, - vAxis: {maxValue: 1, minValue: 0}, - backgroundColor: {stroke: 'black', strokeWidth: 5}} + width:, 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] = ""; - - j++; + j++; @@ -651,7 +561,7 @@ for($i=0;$i<$nnode;$i++) -
+