You are on page 1of 5

Quadrigram.

com Complete example: Dynamic


Local Network from adjacency matrix
In this tutorial we are going to develop a step by step process to build an interactive Local Network
based on two groups of nodes. The purpose of this exercise iso explain theoretical concepts of
information visualization as well as key learning concepts tightly attached to Quadrigram. You can see
the complete example here.
Which are the goals of this exercise?
1.- Build a Network based on an adjacency matrix stored in a MS Excel file
2.- Apply color to nodes depending on their nature
3.- Add a Legend to facilitate label comprehension
4.- Build a system to position dynamically one node of the network in the center of the visualization
We start by loading the data to Quadrigram. In this case, we are going to use a cloud service to generate
a URL of our MS Excel file. You can use Dropbox or any other similar cloud service or even your own
server. You can see more detailed information about the process of loading data with URLs here.
Given the fact that the information to be loaded is stored in a MS Excel file, we need to use its specific
loader module to load it to Quadrigram. The loader module for loading MS Excel data through URLS
is called Load Excel file as Table.
Basically we need to assign the URL of the file to a String module and then connect it to Load
Excel file as Table. Once the data is loaded, we can connect the outlet of Load Excel file as Table
to the inlet of module Table Viewer so that we can see the information loaded and start analyzing its
content.

In Quadrigram we have two different ways of building a Network. Once is called Pairs Table, that
uses aech pair to represent a relation. Lets see with a small example:
column 1 column 2 weight
node1 node2 4
node1 node3 1
We can see that there is a relation between node1 and node2 with a weight of 4 units. There is also a
relation between node1 and node3 with a weight of 1 unit.
The second structure to work with Networks is called adjacency matrix. The adjacency matrix is a
squared matrix that shows in the first column all the nodes and each of the remaining n columns
represent the relations if a single node with the rest of the Network nodes.
Following with our example, we can build an adjancency matrix like this one:
x node1 node2 node3
node1 0 4 1
node2 4 0 0
node3 1 0 0
In this exercise we are going to build a Network of five nodes representing two groups based on an
adjancency matrix stored in a Ms Excel file. We have build an adjancency matrix using MS Excel with
five nodes related to each other. For simplification, we have assigned the same weight to all relations, 1.

Once we have loaded the MS Excel file with the adjacency matrix we can convert that matrix to a
Network data structure. For that purpose, simply connect the outlet of Load Excel file as Table to
the inlet of the module called Convert Table to Network. Once we have the Network itself, we can
vidualize it with the module Local Network.

Our next step is to build a system that assigns a color to each node depending on the group where it
belongs. In our exercise, we have decided that node1 and node2 are going to represent one group ogf
nodes and the rest of nodes (node3, node4 and node5) will represent a second group. In order to
determine which color is linked to each node, we have followed the next steps:
2.1.- Extract all the nodes of the network with module Extract Nodes from Network.
2.2.- Extract the names of the first two nodes (node1 and node2)
2.3.- Create a conversion table that will be used to determine the color of each node

2.4.- Use Replace Values in List module to assign the corresponding color to each node depending
on their group. Replace Values in List receives:
- The conversion table built in step3. This table assigns the same color to node1 and node2
- The source list with all the elements (nodes)
- Default value that will be the value used to be assigned to any element that is not included in the
conversion table.
Basically we say, take this conversion table, scan a list of elements and assign to all the elements not
included in the conversion table another value. In this case we build a conversion table with node1 and
node2 assigned to color A. The module takes the whole list (node1.....node5) and assigns to
node3,node4 and node5 the color B.

3.- Add a Legend to facilitate label comprehension
We can use the module Legend to add a legend for the group of nodes. Legend module needs:
3.1.- List of elements (StringList) to be displayed on the Legend. In out case we have used type1
and type2
3.2.- List of colors to be assigned to each element displayed on the Legend. We have built a ColorList
using our two Colors and the module Create Custom Data Structure that will be served as the
colors to assign to the legend elements.

Local Network positions one node in its center and draws any node related to the centered one in a
radial form. Our network is composed of five nodes, so we want to position each node (one at a time)
in the center of the network. We want to change the node to be centered each three seconds.
Additionally, we are going to set three controls to play, pause and stop the animation.
4.1.- Build the interval of nodes: In order to know how many nodes conform our network, we use the
following process:
4.1.1.- Get the length of the list of nodes - substract 1 - create a custom interval starting at zero and
ending at the length of the list of nodes minus 1.

The module Count Interval will take each three seconds one of the elements included in the interval
(0,1,2,3,4) and use it as the index of the node to be positioned in the center of the Local Network. It
will act as a loop module and the number that it returns will be the induced selection of the Local
Network. The induced selection is the element to be selected, in this case, the node to be positioned in
the center of the Network.
4.2.- Build the controls to play, stop and pause the animation.

Its important to note that module Count Interval needs a numeric input in order to play, pause and
stop the loop counter. If we assign 0, the loop will be stopped, 1 the loop will be paused and 2
the loop will be played. We assigned each number to each Button module and then used the module
Confluence Gate to get the number assigned to the button that last changed. The result of that output
is saved in a variable called lastchanged that will be used in the Count Interval module (see its
inspector panel).

You might also like