Chapter 2. The basics

Please be understanding: either I assume some prerequisites, or the introduction grows huge and boring. Here they are:

  • I assume that Glay and all the packages it depends on are installed. See the section on Installation for information.

  • I hope that you are using a unix-like machine, like GNU/Linux, Solaris, etc. Windows users please see the section on windows.

  • I usually tell you what to type to the "command prompt" called "shell" in the Unix world. I will use the "bash" syntax for commands. To see what sort of shell do you currently use, issue the command

    ps -p $$
    and see the last word. If it is bash, zsh, sh or ksh that means you have a bash-compatible or "Korn" shell. If it is csh or tcsh than you have a "C" shell. In this latter case the commands may not work you verbatim. Please see the section on the C-like shells for information on the most important differences.

  • I assume that the Glay binaries are in your PATH. To check this, try

     glay -a hello
    If you just want to use the Visualization module, you don't even need this, just try the command
    cichlid_pipe -v
    and see if it greets you. Please refer to the section on Installation if these commands do not work.

2.1. How to use it just for visualization

2.1.1. Calling Glay

You need to tell Glay what to do by giving it arguments, for example:

See if glay is really able to read the file:
glay -i filename -d- 2>&1 | less
View a file with coordinate information present in it:
glay -i filename -a visual
The same, but specifying that the format of tha file is "lazy":
glay -i filename lazy -a visual
To run the graph layout algorithm called "J", then dump the result into layed.glay, and the results with a separate command:
glay -i filename -a layout J -d layed.glay
glay -i layed.glay -a visual
The same, but in one command. The -p parameter here is for reading a later discussed parameter file to adjust the behaviour of the layout algorithm:
glay -i filename -p J.mypars -a layout J -d layed.glay -a visual

The arguments are for telling what to do, so --- unlike is most unix programs --- the order of them is in fact important. There are four main parameters: -i stands for input, -a is action, -d is dump, -p means parameter. The usage of them is described in Table 2-1.

Table 2-1. Syntax and meaning of the parameters

-a actionname opt_arg1 opt_arg2 ...

Run an action. The actions are searched first in the environment variable GLAYACTIONPATH, then in the built-in action path. These action directories are searched recursively (which means that one cannot use two different actions of the same name). The actions can have an optional .pm extension. opt_args are optional arguments of the specific action.

-i filename optional_format

Input a file. It is simply a shortcut for -a input filename optional_format. The valid file formats are discussed later. If filename is -, then the file is read from the standard output. If the format argument is omitted, glay tries to use the extension of the filename as a format name. If the extension is not a valid format, it falls back to "native".

-d filename optional_format

Dump the graph and related data to a file. It is simply a shortcut for -a dump filename optional_format. The valid file formats are discussed later. If filename is -, then the file is dumped to the standard output. If an optional_format is not given, glay tries to use the extension as a format name. If the extension is not a valid format name, then it falls back to "native".

-p parameter_file

Read a parameter file. Parameter files are used by some specific actions, for exapmle layout algorithms. The file read by the -p argument is kept in memory, and used later if a corresponding action requires it. Hence one needs to place for example -p J.my_params ahead of the corresponding -a layout J arguments.

2.1.2. File formats and main properties

In this subsection you can see how to provide some data to Glay. Providing the graph for Glay is not the only way to go: you can also ask it to generate a graph that you need, see the next section for information on that.

If you know the Perl language, than it is extremely simple to implement "importers" for some particular graph format, see how to do that.

Here you can read about the formats recognized by the built-in "importers". Reading this also helps to learn about how Glay stores a graph, and what sort of properties of the vertices and edges are recognized by standard modules, for example the layout modules.

FIXME: megirni a sect_ownimporters-et!

All of the following format names can be used in the optional argumentum format_name of -i:

glay -i filename format_name ...

gdc format:

It is a syntax that is also a valid perl program, it looks like this:


vtx "V1", "weight=2.7", "size=0.3", "color=green";
vtx "V2", "weight=2.7", "size=0.3", "color=green";
edge "E1", "size=2", "from=V2", "to=V1", "color=yellow";
The general syntax of the lines is

vtx "label", "tag=value", "tag=value",... ;
edge "label", "tag=value", "tag=value",... ;
The format is not line oriented, the semicolons close a vertex or and edge definition (so you can break the lines if they grow too long). Vertex definitions start by vtx, edge definitions start by edge.

The tags are arbitrary with one exception: the neighbour tag for vertices is reserved for recording the actual neighbours of a vertex. Obviously the to and the from tags are better provided for the edges, as shown in the example above. Currently glay supports only the handling of undirected simple graphs, so interchanging the values of the to and from gives the same result.

Alhough tags are arbitrary, one does not only need to store data but also want the visualization module to interpret it. The currently processed tags are color, size and shape. See the valid values of them in Table 2-2

lazy format:

The same as gdc, minus the ridiculous amount of puctuation characters:


vtx V1 color=green weight=2.7;
vtx V2 color=brown weight=1.4;
edge E1 color=yellow width=2 from=V1 to=V2;
It is optimized for manual input. Conversion is trivial (and probably unnecessary):
glay -i filename lazy -d newfile gdc

native format:

It is a format useful for PERL programmers, others may skip this paragraph: Glay is a PERL program, with C++ extensions. It keeps all the "important" data under the Glay::Data namespace. When dumping in native mode, simply all the variables under this namespace are dumped via Data::Dumper->Dump(). When importing in native mode, the input data is evaluated under the Glay::Data namespace. The format that Data::Dumper->Dump() generates is something like this:


%edge = (
          'E2' => {
                    'width' => '5',
                    'color' => 'grey',
                    'to' => 'V3',
                    'from' => 'V2'
                  },
          ...
       );
%vtx = (
         'V4' => {
                   'color' => 'gold',
                   'weight' => '3.2',
                   'neighbour' => {
                                    'V3' => 'E4',
                                    'V2' => 'E3'
                                  },
                 },
          ...
        );
This is the default format, it can be omitted as a format-argument. The parsing of this format is extreamly fast, since no perl functions are involved, the PERL interpreter does the parsing and the evaluation. However, a great amount of care should be taken if one generates this format by hand: the connectivity information stored in the from and the to tags of edges must be consistent with the content of the neighbour tags of the corresponding vertices.

gem format:

It is the format of the original implementation of the Gem algorithm written by Ingo Bruss and Arne Frick. That format is rather discouraged to use with Glay since it has many unimportant restrictions while not increasing speed or usefullnes in any way. It is included just for the sake of being able to read the files of the original Gem: for exampes to test the included Gem algorithm.

Table 2-2. Tags understanded by the visualization module

color

Its value can be any colorname found in the file rgb.txt of the current X11 disribution. You can use the xcolors program to select one of them visually, or if you do not have it, you can see the file rgb.txt by saying

glay -a showrgbtxt | less

You can also use RGB colors in hexadecimal format as for example "color=#a312ff", or in a shorter form of "color=#a1f". Further you can use decimal numbers for R, G and B in between 0 and 255 as "color=123,0,12".

size

The width in case of an edge and the diameter in case of a vertex. A lot of rescaling is going on through the visualization process, so these are really just relative values. It worth to try values between 0.1 and 1, and adjust as needed.

shape

For vertices it can be any of sphere, ball, cube, pyramid, tetrahedron (ball is equivalent with sphere and pyramid is equivalent with tetrahedron). For edges the value of shape must be one of line, cylinder, box, cube. The defaults are ball and cylinder.

xyz

It is required by the visualization module that the xyz tag of all vertices should be filled in appropriately with the values of the three dimensional coordinate vectors of the points. You can either choose to have itt filled automatically by a layout algorithm, or fill it manually. See the following two sections on this topic.

2.1.3. Calling a layout algorithm

Layout algorithms assign coordinates to the points based on the connectivity information (topology) of the graph. The built-in layout algorithms are based on an energy-function, random walk, and simulated annealing. See Table 2-3 for a description of them.

You can call a layout algorithm alg_name this way:

glay -i filename -a layout alg_name optional_parameters -d filename 
Naturaly only the -a layout alg_name is the important part. If you know how to adjust the behaviour of the algorithm you have chosen by constructing a parameter file par_file, you need to ask glay to read it in before running the layout algorithm:
glay ... -p par_file -a layout alg_name optional_parameters ...
See Chapter 3 for information on the valid contents of the parameterfiles.

The algorithms are capable of continuing their operation if restarted appropriately. See Chapter 3 for information on that.

Table 2-3. Built-in layout algorithms

NameDescription
Gem

A very fast algorithm using integer arithmetic and very simple rules. The quality of the result varies, it worth to try. It is developed by Ingo Bruss and Arne Frick, (Fakultät für Informatik, Universität Karlsruhe). Their actual code has been used while applying just some technical modifications.

J

An algorithm built from scratch utilizing some bright ideas of Gem, although quality and reusablility (hence variability) were considered as the most important goals, not speed. It is the main and best-tested algorithm we use. It has beed first implemented by Johanna Becker, later reworked by Baldvin Kovács.

JX

JX stands for "J eXtended", and has two important goals: First, demonstrating the possibility (and maybe the ease) of the extension of the J algorithm. Second, to implement something useful. That useful extra knowledge of JX is that one is able to constrain the coordinates of specific points to affin subspaces. In human words it means that one can constrain the positions of the points to planes or lines in the 3 dimensional space, specifying the particular plane or line point-by-point. See Chapter 3 for deatails on how to do it. There is no other difference between JX and J, so you can use J if you don't need this particular extra functionality.

2.1.4. Specifying coordinates manually

The only effect of the layout algorithms is that they fill out the xyz tags of the vertices. If you have some useful values, you can set aside of using the layout algorithms, however, you really need to fill the xyz tag of all the vertices.

Technically speaking the xyz tags needs to be arrays of length 3. Table 2-4 shows how to fill them using the built-in fileformats.

Table 2-4. Format of the coordinate parameters

FormatExample
gdc
vtx "label", "xyz=[3, 1.6, 12]", ...;
lazy
vtx label xyz=3,1.6,12 ...;

Note that there are no spaces between the numbers, since spaces are the separators in this format.

gem

There is no way to specify coordinates for the points using this format.

native

Here is a snippet from a "native" file showing how the xyz information appears in it:


         'V2' => {
                   'color' => 'brown',
                   'weight' => '1.4',
                   'neighbour' => {
                                    'V4' => 'E3',
                                    'V3' => 'E2',
                                    'V1' => 'E1'
                                  },
                   'xyz' => [
                              '4.7',
                              3,
                              7
                            ]
                 }

Note that simply filling out some coordinates does not instruct a layout algorithm to keep the particular vertices in that fixed position. If you start a layout algorithm, it usually clears the coordinate information, and provides completely new ones. It is up to the certain algorithm to honor some information arriving at the xyz data member of the vertices, see Chapter 3.

Also note that you don't need to provide the graph and the coordinates at once: you can write your own action (see Section 2.2) to fill out the coordinate information later:

glay -i filename -a my_xyz_action ...

2.1.4.1. Summary

It this section we saw how to start Glay, import files, run some actions (for example visualize graphs) and dump data to files. An all-in one example is

glay -i filename -p J.mypars -a layout J -d layed.glay -a visual

In the following section we see how to get a little more control by implementing some very simple own actions. Knowing the Perl language helps very much, although probably sometimes one can tweak a little some example actions to get the needed results without really getting acquainted with Perl itself.