Using Macros and session (LOG) files in Pajek

Download

Example macros: macro.zip

What is a Macro?

Macro enables you to record a sequence of primitive Pajek commands into file. You can use this file later to execute the saved sequence of commands without typing one by one. When storing macro file, some values will not be stored as constants, so you will have to input them when executing macro next time (for example source and sink vertex in searching shortest paths).

Difference between Macro and LOG file?

Macro executes a sequence of commands on selected objects (networks, partitions,...) that are already loaded in Pajek. Therefore using macros you can execute the same sequence of commands on different objects.
On the other hand LOG or session file executes a sequence of commands from the beginning. Loading and saving objects are also included in a LOG file - there are no parameters (networks, partitions...) that need to be loaded before. LOG file is run using Macro/Repeat Session. LOG files can also be dragged&dropped directly to Pajek windows as well or provided using command line parameters:
pajek c:\logfiles\mylogfile.log
or (in case of spaces in pathname)
pajek "c:\Program Files\logfiles\mylogfile.log"
Pajek always stores commands that you execute in each Pajek run to log files log1.log, log2.log... Everytime you close Pajek a new log file is generated. You can run this log file to repeat all the steps you finished before.

How to record a Macro?

  1. First load all objects (networks, partitions,...) which will be used in macro into memory.
  2. Select objects which will be used in macro first (for example, network which will be first used must be shown in Network ComboBox).
  3. Choose Macro/Record, select the name of macro file (default extension is .mcr).
  4. Use Pajek as usual to define a sequence of commands, you can also add additional comments to macro file using Macro/Add Message.
  5. At the end choose Macro/Record again to stop recording.

How to execute the Macro?

  1. First load all objects that will be used in Macro file into memory.
  2. Select object(s) that will be used first.
  3. Choose Macro/Play, and input additional parameters when asked. Mostly one parameter of each object will be enough (according to type - e.g. one network and one partition), and this parameter must be at the top of appropriate ComboBox, before starting Play. But if you use two different networks as parameters in Macro file, the program will automatically recognise the first (the one that is at the top) but will not find the second, so you will have to tell it, when asked.

Example

The following macro performs topological sort of an acyclic network:
NETBEGIN 2
CLUBEGIN 1
PERBEGIN 1
CLSBEGIN 1
HIEBEGIN 1
NETPARAM 1

Msg Depth Partition
C 1 DEP 1 (10)
Msg Make Permutation
P 1 MPER 1 (10)
Msg Reordering network
N 2 REOR 1 1 (10)
First five sentences store the current state of ComboBoxes. The acyclic network on which we want to execute topological sort must be at the top of Network ComboBox before starting the macro.

Using macros for determining layouts

The following log file will do it for three networks:
  1. read the network file
  2. run layout algorithm (F-R, F-R 3D, K-K)
  3. save the network with layout coordinates in the same file
  4. dispose the network (free memory)

NETBEGIN 1
CLUBEGIN 1
PERBEGIN 1
CLSBEGIN 1
HIEBEGIN 1
VECBEGIN 1

Msg Reading Network   ---    D:\Pajek\DATA\TESTDATA\WRITE.NET
DRAWWINDOW OFF
N 1 RDN D:\Pajek\DATA\TESTDATA\WRITE.NET (56)
E 1 FRUCHT
N 1 WN D:\Pajek\DATA\TESTDATA\WRITE.NET 0 (56)
E 1 EPS 0 0 0 0 0 D:\Pajek\DATA\TESTDATA\write.eps
N 1 DN
Msg Reading Network   ---    D:\Pajek\DATA\TESTDATA\Aho1.net
N 2 RDN D:\Pajek\DATA\TESTDATA\Aho1.net (9)
E 2 FRUCHT3D
N 2 WN D:\Pajek\DATA\TESTDATA\Aho1.net 0 (9)
N 2 DN
Msg Reading Network   ---    D:\Pajek\DATA\TESTDATA\CIRC.NET
DRAWWINDOW ON
N 3 RDN D:\Pajek\DATA\TESTDATA\CIRC.NET (10)
E 3 KAMADA
E 3 BITMAP 0 0 0 0 0 D:\Pajek\DATA\TESTDATA\circ.bmp
N 3 WN D:\Pajek\DATA\TESTDATA\CIRC.NET 0 (10)
N 3 DN
EXIT

Visibility of Draw window

DRAWWINDOW OFF
All layouts in Draw window are omitted (computed but not drawn).
DRAWWINDOW ON
Layouts in Draw window are visible during batch execution. Default is ON.

Layout in Pajek DRAW window

E net DRAW clu vecx vecy clu2 clu3
colors of vertices are determined by partition clu and x and y sizes by vectors vecx and vecy. Color of font of vertices can be determined by partition clu2 and size of font of vertices by partition clu3 (otherwise input 0 0).

DRAW commands are written to log file only when Draw is called explicitly from Pajek main window, e.g. using Draw/Network+Partition, but not for example when Redraw is clicked.


Optimization using Kamada-Kawai algorithm

E net KAMADA
or, for drawing networks with several components
E net KAMADACOMP

Optimization using 2D Fruchterman-Rheingold algorithm

E net FRUCHT

Optimization using 3D Fruchterman-Rheingold algorithm

E net FRUCHT3D

GIVENZ ON
Keep the current z-coordinate during the optimization
GIVENZ OFF
Remove freezing z-coordinate.

Determining layout using EigenVectors

E net EIGEN val1 val2 val3 LineValues Start
val1,val2,val3: eigenvalues
LineValues: n-forget, s-similarities, d-dissimilarities
Start: Start computing eigenvalues (use 0 as default)


Export to EPS

E net EPS clu vecx vecy clu2 clu3 EPSfile
colors of vertices are determined by partition clu and x and y sizes by vectors vecx and vecy. Color of font of vertices can be determined by partition clu2 and size of font of vertices by partition clu3 (otherwise input 0 0).


Export to SVG

E net SVG clu vecx vecy clu2 clu3 SVGfile SVGtype SVGsubtype
colors of vertices are determined by partition clu and x and y sizes by vectors vecx and vecy. Color of font of vertices can be determined by partition clu2 and size of font of vertices by partition clu3 (otherwise input 0 0).

SVGtypeSVGsubtype Description
1 0 General
2 0 Labels/Arcs/Edges
3 0 Partition/Classes
4 0 Partition/Nested Classes
5 0 Partition/Classes with semi-lines
6 1 Line Values/Nested Classes
6 2 Line Values/Nested Classes - Use Colors
6 3 Line Values/Nested Classes - Use GreyScale
6 4 Line Values/Nested Classes - Different Widths
6 5 Line Values/Nested Classes - GreyScale and Different Widths
6 6 Line Values/Nested Classes - Use Colors and Different Widths
7 1 Line Values/Classes
7 2 Line Values/Classes - Use Colors
7 3 Line Values/Classes - Use GreyScale
7 4 Line Values/Classes - Different Widths
7 5 Line Values/Classes - GreyScale and Different Widths
7 6 Line Values/Classes - Use Colors and Different Widths
8 1 MultipleRelationsNetwork


Export to JPEG

E net JPEG clu vecx vecy clu2 clu3 BMPfile CompressionQuality GreyScale
colors of vertices are determined by partition clu and x and y sizes by vectors vecx and vecy. Color of font of vertices can be determined by partition clu2 and size of font of vertices by partition clu3 (otherwise input 0 0).
CompressionQuality is number in a range [0..100] - higher values means better quality but larger filesize.
If GreyScale is set to 0 exported layout will be drawn in colors (othewise in greyscale).


Export to BITMAP

E net BITMAP clu vecx vecy clu2 clu3 BMPfile
colors of vertices are determined by partition clu and x and y sizes by vectors vecx and vecy. Color of font of vertices can be determined by partition clu2 and size of font of vertices by partition clu3 (otherwise input 0 0).


Export to X3D

E net X3D clu vecx vecy clu2 clu3 X3Dfile VerticesSize LinesSize
colors of vertices are determined by partition clu and x and y sizes by vectors vecx and vecy. Color of font of vertices can be determined by partition clu2 and size of font of vertices by partition clu3 (otherwise input 0 0). VerticesSize determines vertices resize factor and LinesSize lines resize factor


Export to KineMage

E net MAGE clu vecx vecy MAGEfile VerticesType VerticesSize NeighbourClusters ExportType
colors of vertices are determined by partition clu and x and y sizes by vectors vecx and vecy. VerticesType: 1-spheres, 2-labels, 3-balls;
VerticesSize: vertices resize factor
NeighbourClusters: how many neighbour clusters to show
ExportType: 0 - Current Network Only; 1 - Current and all Subsequent; 2 - Multiple Relations Network.


Export to VRML

E net VRML clu vecx vecy VRMLfile VerticesSize LinesSize
colors of vertices are determined by partition clu and x and y sizes by vectors vecx and vecy. VerticesSize determines vertices resize factor and LinesSize lines resize factor


Export to MDLMOLfile

E net MDLMOL clu vecx vecy MDLfile VerticesSize
colors of vertices are determined by partition clu and x and y sizes by vectors vecx and vecy. VerticesSize determines vertices resize factor


Rotating layout

E net ROT3D x y z Angle Step
x,y,z: axis (normal) of rotation
Angle: angle to rotate layout for
Step: step of rotation (smaller step, slower rotation)


Drawing on a CIRCLE

E net CIRCULAR


Drawing on a CIRCLE in RANDOM order

E net RANDOMCIRCULAR


Drawing on a CIRCLE using PERMUTATION

E net PERMUTCIRCULAR per
ordering is determined by permutation per


Drawing on several CIRCLES using PARTITION

E net PARTCIRCULAR clu
circles are determined by partition clu


Drawing in Layers

E net LAYERS?? clu
layers are determined by partition clu. Four options for drawing in layers:
LAYERSNY - 2D layers in y direction
LAYERSRY - 2D layers in y direction + random in x
LAYERSNZ - 3D layers in z direction
LAYERSRZ - 3D layers in z direction + random in xy

How to ensure that layouts will always look the same whenever log file is run?

Store parameters (sizes of windows, vertices, permutation of partition colors...) that you want to keep in INIfile using File/Ini File/Save or using command in log file

SAVEINI INIfile
Before running the log file it is recommended to load the saved configuration in INIfile using File/Ini File/Load or by including command
LOADINI INIfile
in corresponding log file before commands producing layouts

Repeating sessions by command line by providing INI and LOG files

If you want to be sure that Pajek will use some special settings (e.g. settings you select in Options/ReadWrite, colors, sizes,...) you should (when running Pajek as a batch) provide the settings file as parameter as well, e.g.:

pajek c:\logfiles\mysettings.ini c:\logfiles\mylogfile.log

Download

Example macros: macro.zip