Using Macros and session (LOG) files in PajekDownloadExample macros: macro.zipWhat 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.logor (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?
How to execute the Macro?
ExampleThe 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 layoutsThe following log file will do it for three networks:
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 OFFAll layouts in Draw window are omitted (computed but not drawn). DRAWWINDOW ONLayouts in Draw window are visible during batch execution. Default is ON. Layout in Pajek DRAW window E net DRAW clu vecx vecy clu2 clu3colors 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 ONKeep the current z-coordinate during the optimization GIVENZ OFFRemove freezing z-coordinate. Determining layout using EigenVectors E net EIGEN val1 val2 val3 LineValues Startval1,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 EPSfilecolors 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 SVGsubtypecolors 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 JPEG E net JPEG clu vecx vecy clu2 clu3 BMPfile CompressionQuality GreyScalecolors 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 BMPfilecolors 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 LinesSizecolors 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 ExportTypecolors 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 LinesSizecolors 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 VerticesSizecolors 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 Stepx,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 perordering is determined by permutation per
Drawing on several CIRCLES using PARTITION E net PARTCIRCULAR clucircles are determined by partition clu
Drawing in Layers
E net LAYERS?? clulayers 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 DownloadExample macros: macro.zip |