Using the Interpreter

The Interpreter is the most powerful part of the Guess program, but it is also the most complicated to learn how to use. It allows you to access the different qualities of individual nodes, groups of nodes, edges, and the entire graph.

In this section, code that you should type into the Interpreter will be in italics and seperated from the rest of the text.

Go ahead and bring the Interpreter back into view by clicking on the "Interpreter" tab at the bottom of the Guess window.

Accessing Attributes

Attributes are something that we have alluded to so far, but have not throroughly described. Both edges and nodes have several different attributes associated with them. This is the information that is displayed in the Information Window when you hover over a node or edge. We can also access this information using the Interpreter. We do this by using the '.' (dot) operator. For example, to access Jack's color, we would type:

Jack.color

The Interpreter then prints out Jack's color. Go ahead and try it. In this case, Jack's color is blue.



In order to access edges, we need to type a little more. In DukeGuess, edge's are defined by their end nodes. DukeGuess uses the "-" symbol to represent the edge between two nodes. For example, an edge between Jack and Kim would be represented as "Jack-Kim" or "Kim-Jack". We can then access this node's color by typing:

(Jack-Kim).color

We have to put "Jack-Kim" within parenthesis because the '.' operator has a higher priority than '-'. This means that DukeGuess would try to find an edge between Jack and Kim's color (which is green) instead of first finding the edge between Jack and Kim, and then finding that edge's color.


Changing Attributes

It is also possible to change the value of attributes for nodes and edges. To do this we use both the '.' and the equals sign, '=' to "assign" the attribute a new value. For an example of this, lets first make Jack purple, and then make the edge between Jack and Kim orange. Here is the code:

Jack.color = purple
(Jack-Kim).color = orange

Now it is easier to find Jack and the edge between Jack and Kim.



Below is a list of node attributes that you may access, ones that are immutable are marked with an asterisk(*)

Final Example

Here is a final example that will help you put together a couple of the things you have learned.
Let's say we want to investigate what impact the removal of Jack and all of his neighbors would have on the "24" graph. First, make sure you have the "twentyFour.gdf" file loaded and that you have opened the Node Functions Panel. Select Jack and highlight his neighbors. Now shift click Jack and all of his neighbors and click on "Save Group" to save these nodes to a group. Check the image below to make sure you got all of the nodes.

Now save this group under the name "friends". To make it appear like we have removed Jack and his friends, we need to type some commands into the interpreter.

friends.visible = 0

You'll notice something strange about this line of code -- it doesn't contain any node names! In DukeGuess, if you have a group of nodes you can access and change the same attribute for all nodes in the group by using the '.' (dot) operator on the group name the same way you would use it on a node name.
You should end up with a graph that looks something like the one below. Clearly Jack and his friends are a key portion of this social network! Also notice that DukeGuess makes invisible edges attached to invisible nodes


< Back Contents