Information on how to incorporate this facility in your web application.
NetDy is written in JavaScript, so it is embedded withnin regular HTML pages. To incorporate it within your web application you have to do two small things:
- Create in your application a link to NetDy that will open NetDy within a new window. Here is an example of how you can do this. The right side shows the HTML script, the left side show how this script is rendered by your browser. To open NetDy, click on its link. A new window will open showing NetDy in full glory.
NetDy
<a href="javascript:void(0)" onClick="NETDY =open('frame.html','NETDY','resizable')"
>;<h1 style="font-size:18pt;color:gold">Net<font color="red">D</font>y<'/font><h1></a>
- Create in your application the following JavaScript script:
<script language="Javascript"> <!-- /* EXAMPLES is a JavaScript array of objects, each of which represent a network */ My_Examples = NETDY.EXAMPLES; // --> </script>You can then refer to the array My_Examples in your application. Each element of My_Examples, say My_Examples[k] represents a network instance and consists of the following four elements:
- My_Examples[k].title is a string representing the title of the network.
- My_Examples[k].NodeNames is an array representing the names of the nodes of the network. That is, My_Examples[k].NodeNames[i] the the title of the node representing the i-th row/column of the adjacency matrix of the network. If the network consists of N nodes then typically this array will be equal to [1,2,3,...,N]. However, if the users deleted some of the nodes she created, then My_Examples[k].NodeNames could be an array of non-contiguous integers, eg [4,5,8,9,10].
- My_Examples[k].comments is a string consisting of the comments specified by the user when she saved the network.
- My_Examples[k].labels is a square matrix representing the adjacency matrix of the network, so that My_Examples[l].labels[i][j] represents the label associated with the arc connecting the node corresponding to row i of the matrix to the node corresponding to column j of the matrix. This label is stored as a string exactly the way the user specified it. In particular, the label is empty (equal to "null") if there is no arc from node My_Examples[k].NodeName[i] to node My_Examples[k].NodeName[j].
For example, suppose that the third network the user constructed the following network and saved it as "My favourite network!" :
Also supposed that when she saved the network, the user specified the following comment: "An example for the next tutorial".
Then the adjacency matrix in this case is the 7 by 7 matrix specified by
1 2 3 4 5 6 7 1 11 9 2 12 23 3 8 10 4 10 10 5 9 6 7 7 Then, in this case we have:
My_Examples[3].title == "My favourite network!"
My_Examples[3].comments == "An example for the next tutorial"
My_Examples[3].NodeNames == [1,2,3,4,5,6,7]My_Examples[3].labels is the 7 by 7 matrix displayed above, eg. My_Examples[3].labels[2][3] = 23 and My_Examples.labels[3][6] = null.
it is really a very simple arrnagemnt.
For your convenience I provide a very simple application incorporating NetDy. The application provides the user a link to NetDy so she can use it to construct her favourite networks and save them (in memory). It also consists of a button, called "Show Me". When the user clicks this button, the application will display (in a separate window) the data pertaining to all the networks the user has saved up to that point in time.
Here is the script of the entire application.
<html> <head> <title>My favourite Application</title> <script language="JavaScript"> <!-- function Show_Me(){ if(!NETDY.EXAMPLES){alert('Sorry, you have not yet saved any example!");return} My_Examples = NETDY.EXAMPLES var K = My_Examples.length var t = "" EXWIN = open("","EXWIN","resizable,scrollbars") for(k = 0;k' t += ' ' + Example: Example.title + '
' t += '' + Comments: ' + Example.comments + '
' t += '' + Comments: ' + Example.comments + '
' t += '' + Adjacency matrix:
' var t ='' t += '
' for(i=0;i<=M;i++){ t += ' ' for(j=0;j<=M;j++){t +=' ' +Names[j] + ' '} t += '' } t += ' ' + Names[i] + ' ' for(j=0;j<=M;j++){t +='' + Labels[i][j] + ' ' } t +='