Using Macro in Pajek

Vladimir Batagelj and Andrej Mrvar

University of Ljubljana



What is 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).

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.