Skip to main content
Mathematics LibreTexts

4.6: A few hints on data handling with NetDraw

  • Page ID
    7670
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    Input

    There are several ways to get data into NetDraw. Probably the simplest is to import data from UCINET or Pajek. The File>Open command lets you read a UCINET text (DL) file (discussed elsewhere), and existing UCINET dataset, or a Pajek dataset. This menu also is used to access data that have been stored in the native data format of the NetDraw program (.VNA format). Once the data has been imported with the Open command, the node and line attribute editors of NetDraw can be used to create a diagram that can be saved with colors, shapes, locations, etc.

    A second method is to build a dataset within NetDraw itself. Begin by creating a random network (File>Random). This creates an arbitrary network of 20 nodes. You can then use the node attributes editor (Transform>Node Attribute editor) and the link editor (Transform>Link Editor) to modify the nodes (and add or delete nodes) and their attributes; and to create connections among nodes. This is great for small, simple networks; for more complicated data, it's best to create the basic data set elsewhere and import it.

    The third method is to use an external editor to create a NetDraw dataset (a .vna file) directly. This file is a plain ascii text file (if you use a word processor, be sure to save as ascii text). The contents of the file is pretty simple, and is discussed in the brief tutorial to NetDraw. Here is part of the file for the Knoke data, after we have created some of the diagrams we've seen.

    *Node data
    "ID", "General", "Size", "Govt"
    "1" "1" "3" "1"
    "2" "1" "2" "0"
    .
    .
    "9" "0" "2" "1"
    "10" "0" "1" "0"
    *Node properties
    ID x y color shape size shortlabel labelsize labelcolor active
    "1" 51 476 255 2 16 "Coun" 11 0 TRUE
    "2" 451 648 16711680 2 11 "Comm" 11 0 TRUE
    .
    .
    "9" 348 54 255 1 11 "Welfare" 11 0 TRUE
    "10" 744 801 16711680 1 6 "West" 11 0 TRUE
    *Tie data
    FROM TO "KNOKI" "KNOKM"
    "1" "2" 1 0
    "1" "5" 1 1
    .
    .
    "9" "3" 0 1
    "9" "8" 0 1
    *Tie properties
    FROM TO color size active
    "1" "2" 0 1 TRUE
    "1" "5" 0 1 TRUE
    .
    .

    "9" "3" 0 1 FALSE
    "9" "8" 0 1 FALSE

    There are four sections of code here (not all are needed, but the *node data and *tie data are, to define the network structure). *Node data lists variables describing the nodes. An ID variable is necessary, the other variables in the example describe attributes of each node. The (optional) *Node properties section lists the variables, and gives values for ID, location on the diagram (X and Y coordinates from the upper left corner), shape, size, color, etc. Usually, one will not create this code; rather you input the data, use NetDraw to create a diagram, and save the result as a file -- and this section (and the *Tie properties) is created for you.

    The *Tie data section is necessary to define the connections among the nodes. There is one data line for each relation in the graph. Each data line is described by its origin and destination, and value. Here. since there are two relations, "KNOKI" and "KNOKM" there are two values -- each of which happens, in our example, to be binary (but they could be valued).

    The *Tie properties section is probably best created by using NetDraw and saving the resulting file. Each tie is identified by origin and destination, and its color and size are set. Here, certain ties are not to be visible in the drawing (the "active" property is set to "FALSE").

    Output

    When you are working with NetDraw, it is a good idea to save a copy of your work in the format (.vna, above) that is native to the program (File>Save Data As>Vna). This format keeps all of the information about your diagram (what's visible and not, node and line attributes, locations) so that you can re-open the diagram looking exactly as you left it.

    You may also want to save datasets created with NetDraw to other program's formats. You won't be able to save all of the information about node and line properties and locations, but you can save the basic network (what are the nodes, which is connected to which) and node attributes. File>Save Data As>Pajek lets you save the network, partitions of it (which record attributes), and clusterings in Pajek format. File>Save Data As>UCINET lets you save the basic network information for binary or valued networks (UCINET needs to know which) and attributes (which are stored in a separate file in UCINET).

    The whole point of making more interesting drawings of graphs, of course, is to be able to use them to illustrate your ideas. There are several possibilities.

    Screen capture programs (I used SnagIT) can take pictures of your graphics that can be then saved in any number of formats, and edited further by external graphics editors (perhaps to add titles, annotations, and other highlights).

    File>print, of course, does just that.

    File>Save Diagram As let's you save your diagram in three of the most common graphics formats (Windows Metafile, bitmap BMP, or JPEG). Once saved, these file formats can be further edited with graphics editing programs to be inserted into web or hard-copy documents.


    This page titled 4.6: A few hints on data handling with NetDraw is shared under a not declared license and was authored, remixed, and/or curated by Robert Hanneman & Mark Riddle.

    • Was this article helpful?