Print

Print


*****  To join INSNA, visit http://www.sfu.ca/~insna/  *****

Hello Emmanuel -

How's it in Toronto? I heard it is a great place.

I don't recall if UCINet is capable of doing that. But, I have a small script that converts a matrix data into a "one-vector" column.
It is written in PHP, which you can run it from your webpage directory.

Upload your matrix data (as a text file) into your webpage directory (matrixData.txt, for example).

Just copy and paste the below portion; and change the filename in the script (it is test.txt) to your matrix data file name; then save the script as a file (oneVector.php, for example). Put it under your web page directory (Note that your directory should be capable of running PHP script).

And run the script with your web browser by calling:
http://your.server.name/~yourAccount/oneVector.php

You can see how the script is working at:

http://scils.rutgers.edu/~hkimscil/oneVector.php

my input data looked as below:

 A  B  C  D
A  0  1  1  1
B  1  0  1  1
C  1  1  0  1
D  0  0  1  0
E  1  1  1  0

Hope this helps a bit....

-hyo

== script begins
<?php

// this small script reads a file whose content is a matrix
// data. It converts the matrix into one-vector column data.
// written by hyo kim (hkimscil), SCILS, Rutgers
// email: [log in to unmask]
// http://scils.rutgers.edu/~hkimscil/

// requirement for using the script:
/* ////////////////////////////////////////////////////////
You need a web page account, which is capable of running
php script.

For example, I have a web page at:
http://scils.rutgers.edu/~hkimscil/

My account is at a directory called "hkimscil"
in the server, scils.rutgers.edu
And all the html files and scripts are located
under "hkimscil/public_html/"

My server allows users to run PHP script. Check your system
with your system administrator. Most servers allow nowadays.

NOTE that the name of "public_html" depends on your server.

Save this script (copy the whole content from "<?php" to "?>"
Change the file name ("text.txt" in the script) into the name of your
matrix data. Then save it as oneVector.php

Put (upload) it in the directory, ~yourAccount/public_html/
Then run it with any web browser by invoking
http://your.server.name/~yourAccount/oneVector.php

///////////////////////////////////////////////////////////
*/
$file="test.txt"; // change text.txt to your matrix data filename here.
$c = readFileContent($file);
oneVector($c);


function readFileContent($file) {
        $src = @fopen($file, "r");
        if (!$src) {
                $title="Warning...";
                $content="the file <b>$file</b> is missing...";
                $wholeContent="the file <b>$file</b> is missing...";
        }
        else {
        $i=0;
        $r_line="";
                while(!feof($src)) {
                        $line = fgets($src, 1024);
                        $r_line[$i]=$line;
                        trim($r_line[$i]);
                        $r_line[$i]=explode(" ",$r_line[$i]);
                        $i++;
                }
        }
        return $r_line;
}

function oneVector($array) {

$h=array_shift($array[0]);
// print_r($array[0]);


echo "Matrix input: <br>\n";
echo "<table>";
        for ($j=0;$j<sizeof($array);$j++) {
        echo "<tr>";
        for ($i=0;$i<sizeof($array[$j]);$i++) {
                echo "<td>";
                echo "{$array[$j][$i]} ";
                echo "</td>";
        }
        echo "</tr>";
        }
echo "</table>";
echo "<br> \n";


echo "<p />";

        for ($j=1;$j<sizeof($array);$j++) {
                for ($i=1;$i<sizeof($array[0]);$i++) {
                        if ($j==$i) {}
                        else { echo "{$array[$j][0]}{$array[0][$i]} {$array[$j][$i]}<br>"; }
                }
        }
}


?>
== script ends

-----Original Message-----
From: Social Networks Discussion Forum [mailto:[log in to unmask]]On Behalf Of Emmanuel Koku
Sent: Wednesday, October 02, 2002 2:09 AM
To: [log in to unmask]
Subject: Matrices into EdgeLists1


*****  To join INSNA, visit http://www.sfu.ca/~insna/  *****

Hi,

I have a square matrix:

  A B C D
A 0 1 1 1
B 1 0 1 1
C 1 1 0 1
D 0 0 1 0

Is there anyway UCINET can convert this matrix into an edgelist1 data
format such at I can have:
AB1
AC1
AD1
BA1,
BC1
BD1,
Etc, etc.

Thanks in anticipation of your assistance - Emmanuel.

------------------------------------------------------------------
Emmanuel F. Koku                        [log in to unmask]
                Doctoral Student in Sociology
                Centre for Urban and Community Studies
                University of Toronto
                455 Spadina Avenue, Toronto, Canada M5S 2G8
Tel: +1-416-925-0884                    Fax: +1-416-925-3877
------------------------------------------------------------------

_____________________________________________________________________
SOCNET is a service of INSNA, the professional association for social
network researchers (http://www.sfu.ca/~insna/). To unsubscribe, send
an email message to [log in to unmask] containing the line
UNSUBSCRIBE SOCNET in the body of the message.

_____________________________________________________________________
SOCNET is a service of INSNA, the professional association for social
network researchers (http://www.sfu.ca/~insna/). To unsubscribe, send
an email message to [log in to unmask] containing the line
UNSUBSCRIBE SOCNET in the body of the message.