Exporting pictures from Pajek to EPS
Vladimir Batagelj and Andrej Mrvar
University of Ljubljana
This procedure exports picture you obtain using Pajek to PostScript
description. If you want to control some general layout parameters of the
picture, you must change default values using Export/Options in Draw window:
Right 15 %% additional border around ...
Left 15 %% ... picture in all 4 directions
Background color No %% Color of background
Border Color No %% Color of border
Border Radius 0 %% Border raduis
Border width 1 %% Border width
shapes_file SHAPES.CFG %% file with shapes definitios
Remember (and to have feeling how big number 15 in additional border is):
x and z coordinates of vertices must be between 0 and 1.
When Postscript picture is obtained, the square [0,1]x[0,1]
is transformed to [0,500]x[0,500].
Crayola colors are used (CMYK - combination of Cyan-Magenta-Yellow-blacK).
They are defined in file drawnet.pro that is added in the beginning of any
EPS picture you made. You can also define and add your own colors.
Be careful - Postscript is case sensitive.
In file shapes.cfg shapes of vertices (ellipses, boxes,...) are defined.
Specify full path name (or double click on Edit field) if you want to use
special file. If the file cannot be found default file will be generated
on the directory where you get EPS picture.
If you have no labels on the picture when you call Export there will also
be no labels in EPS picture, otherwise numbers/labels like in Pajek will
be shown. If you are looking at the picture using Draw/Partition (some
partition of the network is shown using different colors), similar colors
will be automatically used in EPS picture too.
But you can for every vertex and line specify how it should be drawn
(colors, shapes, sizes, patterns, rotations, widths...).
How to do that is explained in details in next section.
Pajek - Definition of Network (and its Picture) on Input Ascii File
A kind of standardized language is used for describing networks.
The following reserved words are used:
- *Vertices n - definition of vertices follows.
n is number of vertices. Each vertex is described using
following description line:
vertex_num label x y shape [changes of default parameters]
Default values can be changed for each vertex in definition line,
- vertex_num - vertex number (1, 2, 3...)
- label - if label starts with character A..Z or 0..9 first blank
determines end of the label (example: vertex1), labels
consisting of more words must be enclosed in pair of
special characters (example: "vertex 1")
- x, y - coordinates of vertex (between 0 and 1)
- shape - shape of object which represents vertex. Shapes are defined
in file SHAPES.CFG (ellipse, box, diamond, cross, empty)
Meaning of parameters in this file:
- SHAPE s - s is external name of vertex (used for descriptions)
- sh - sh can be ellipse, box, diamond, cross, empty
This is the name of PostScript procedure that
actually draws object (procedure is defined in
- s_size - default size
- x_fact - magnification in x direction
- y_fact - magnification in y direction
- phi - rotation in degrees of object in + direction (0..360)
- r - parameter used for rectangle and diamond for describing
radius of corners (r=0 rectangle, r>0 roundangle)
- q - parameter used for diamonds - ratio between top and
middle side of diamond (try q=0.01, q=0.5, q=2, ...)
- ic - interior color of vertex
(colors defined in drawnet.pro, case sensitive!)
- bc - boundary color of vertex
- bw - boundary width of vertex
- lc - label color
- la - label angle in degrees (0..360)
- lr - distance of beginning of vertex label from vertex center
(radius - first polar parameter)
- lphi - position of label in degrees (0..360)
(angle phi - second polar parameter)
- fos - font size
- font - PostScript font used for writing labels
(Helvetica, Courier, ...)
- HOOKS - positions where edges can join the selected shape -
according to s_size. Three different ways to specify
- CART - x y - positions in cartesian coordinates (x,y)
- POLAR - r phi - positions in polar coordinates
phi is positive angle (0..360)
- CIRC - r phi1 - iteration of positions in polar
coordinates r - radius, phi=k*phi1
k=1,2,..; k*phi1 <= 360
1 "vertex one" 0.3456 0.1234 box ic White fos 20
Explanation: White box will represent vertex 1, label (vertex one)
will be written
using font size 20.
List of colors (names are case sensitive) can be found in file crayola.ps
- *Arcs (or *Edges) - definition of arcs (edges). Format:
v1 v2 value [additional parameters]
These three parameters must always be present. If no other parameter is
specified, the default arc will be black, straight, solid arc with
- v1 - first vertex number
- v2 - second vertex number
- value - value of arc from v1 to v2
Arrow will be drawn at the end of the edge (at second vertex).
- if value is negative, dotted line will be used instead of solid,
- if loop (arc to itself) is found, bezier loop will be drawn,
- if arcs in both directions are found two curved bezier arcs will
As we mentioned, hooks are used to specify exact position where line
Special shapes of lines can be defined using combinations of
alpha1, k1, alpha2, k2:
- h1 - hook at starting vertex (v1)
(0 - center, -1 the closest, 1, 2.. user defined)
- h2 - hook at second vertex (v2)
- w - width of line
- c - color of line
- p - pattern of line (Solid, Dots, Dashed)
- a - type (shape) of arrow (A or B)
- s - size of arrow
- a1 - angle at vertex 1
- k1 - velocity at vertex 1
- a2 - angle at vertex 2
- k2 - velocity at vertex 2
- ap - position of arrow
- ap = 0 - arrow at second vertex
- 0 < ap <= 1 - proportional distance from second vertex
(according to line length)
- ap > 1 - absolute distance
(remember that size of PostScript picture is
at most [0,500]x[0,500])
- l - line label (look at description of label format at shapes)
- lp - label position (look at ap)
- lr - label radius (position of center text from point on edge )
- lphi - label radius (angle of center text according to point on edge )
(lr and lphi are polar coordinates)
- lc - label color
- la - label angle
(0 < la < 360 - relative to edge)
(la >= 360 - absolute angle according to x axis)
- fos - font size of label
- font - PostScript font used for writing labels (Helvetica, Courier, ...)
- alpha1=alpha2=0, k1>=0, k2>=0 - straight line
- alpha1=alpha2=0, k1=-1, k2>0 - oval edge with radius k2 (measure
of radius is absolute as explained above)
- alpha1=alpha2=0, k1=-1, k2<0 - second possible oval edge with radius -k2
- alpha1=alpha2=0, k1=-2, k2>0 - circular arc with radius k2 in positive
- alpha1=alpha2=0, k1=-2, k2<0 - second possible circular arc with radius -k2
in positive direction
- alpha1=alpha2=0, k1=-3, k2>0 - circular arc with radius k2 in negative
- alpha1=alpha2=0, k1=-3, k2<0 - second possible circular arc with radius -k2
in negative direction
- alpha1=alpha2=0, k1=-4 - double edge
- alpha1 or alpha2 <> 0, k1>0, k2>0 - Bezier curve
(if angle1 and angle2 have different signs line goes from one to
another side of straight line connecting both vertices,
if angle1 and angle2 have the same sign - line stays on the same side
of straight line connecting both vertices)
- *Edges - definition of edges.
Everything is the same, just type (a), size (s) and position (ap) of
arrow must be omitted.
Two different ways of exporting
- PS - Export to Postscript (.PS) without header (drawnet.pro).
Use it to spare space, if you have many pictures and your
word processor enables you to define the header separately
(like in laTEX).
- EPS - Export into file with Encapsulated PostScript description (.EPS).
Drawnet.pro is already inserted in the beginning.
The picture is complete, you can include it into text,
make it bigger or smaller (without losing quality),
rotate it, print it on Postscript printer,
view it with GhostScript viewer, convert it to GIF, JPG...
1 "A1" 0.0938 0.0896 ellipse x_fact 1 y_fact 1
2 "Bb" 0.8188 0.2458 ellipse x_fact 1 y_fact 1
3 "C" 0.3688 0.7792 ellipse x_fact 1
4 "D2" 0.9583 0.8563 ellipse x_fact 1
1 1 1 h2 0 w 3 c Blue s 3 a1 -130 k1 0.6 a2 -130 k2 0.6 ap 0.5 l
► "Bezier loop" lc BlueViolet fos 20 lr 58 lp 0.3 la 360
2 1 1 h2 0 a1 120 k1 1.3 a2 -120 k2 0.3 ap 25 l "Bezier arc"
► lphi 270 la 180 lr 19 lp 0.5
1 2 1 h2 0 a1 40 k1 2.8 a2 30 k2 0.8 ap 25 l "Bezier arc" lphi 90 la 0 lp 0.65
4 2 -1 h2 0 w 1 k1 -2 k2 250 ap 25 l "Circular arc" c Red lc OrangeRed
3 4 1 p Dashed h2 0 w 2 c OliveGreen ap 25 l "Straight arc" lc PineGreen
1 3 1 p Dashed h2 0 w 5 k1 -1 k2 -20 ap 25 l "Oval arc" c Brown lc Black
3 3 -1 h1 6 w 1 h2 12 k1 -2 k2 -15 ap 0.5 l "Circular loop"
► c Red lc OrangeRed lphi 270 la 180
The character ► denotes the continuation of the line.
And the resulting Links.eps file.
You have to set some options in Pajek's draw window: for example
Options / Lines / Mark Lines / with labels
to activate the display of line labels.
This description Lines.net
works also in SVG:
Back to Pajek manual.