Skip to main content
Jump to: navigation, search

Importing a Pajek Graph

Revision as of 06:41, 9 December 2010 by (Talk | contribs) (minor format changes)

PajekNetGraphGenerator Example Project

STEM allows users to create a custom graph using Pajek.
Running the downloadable pajek scenario (with edges displayed) the map view should appear as shown above.
Pajek ([1]) uses a kind of standardized language for describing networks. Some examples might be found here: A subset of this language is interpreted by the PajekNetGraphGenerator to import arbitrary graphs into STEM. The PajekNetGraphGenerator allows creating user-defined graphs for STEM and is based on the Pajek format.

An example project available for download may be found on the STEM website [2]. This is a standard STEM project that you may import into your workspace. It contains a graph generated using the Pajek Graph Generator. It also contains examples of the original Pajek files used to create the graphs found in the project. The files are located in the 'Doc' directory of the project. Also in that directory you can find additional documentation. Read the PajekStem_Format.doc for further information about the modified Pajek format. The PajekNetGraphGenerator is available in the graph creation dialogue of STEM. Please see the page Creating a new Graph for information on using this dialog.

The Archive

The archive contains the STEM project MultiPopulationExample_PajekGraphs, a modification of the STEM project MultiPopulationExample. The modification replaces the graph "3x3.graph" in the MultiPopulationNoVillageExample scenario with the imported graph "CC.graph".

The imported Pajek NETs were created with the simple Excel macro Pajek2STEM.xls. This macro allows the easy modification of Pajek NETs; it is not necessary, but makes things far easier - especially for complex graphs. The macro imports a Pajek NET, allows for modification and adding of additional parameters and exports a Pajek NET that is still compatible with Pajek. The usage of this macro is straightforward. It is generally applicable to all Pajek NETs.

Pajek allows (x,y,z)-coordinates between 0 and 1 only. STEM rounds coordinates to
two decimal places. This might result in strange shapes of the nodes. This
behaviour can be avoided if the coordinates are multiplied by a large factor, e.g.
by using the Excel macro.
Be aware:
the resulting file with coordinates larger than 1 cannot be imported into Pajek.


The PajekNetGraphGenerator was created and developed by the department of Biological Safety of the Federal Institute for Risk Assessment in Germany.

Armin A. Weiser, Matthias Filter
Dept. Biological Safety 
Federal Institute for Risk Assessment
12277 Berlin


PajekNetGraphGenerator and the STEM-related Format extension to Pajek

The following reserved words are supported in the current Pajek Import implementation:

1. *Vertices n

  • n denotes the number of vertices in the graph.

In STEM nodes are the equivalent of vertices. The keyword "*Vertices n" is the starting point for the section, in which each vertex is described using following format:

vertexnum label x y [z] [shape] [additional optional parameters]

  • vertexnum – vertex number (1; 2; 3 : : : n). Successive numbering of vertices/nodes is obligatory.
  • label – if label starts with character a..zA..Z or 0..9 first blank determines end of the label (e.g., vertex1), labels consisting of more words must be enclosed in pair of special characters (e.g., ”vertex 1”). The definition of a label is obligatory.
  • x, y, z – coordinates of vertex. The z coordinate is ignored in STEM. In Pajek the coordinates have values between 0 and 1, for STEM the values are not limited. x and y coordinates are obligatory for STEM.
  • shape – shape of object which represents vertex. The following shapes are supported by the PajekNetGraphGenerator: triangle, cross, ellipse, box, diamond. In STEM ellipse is represented as circle and box and diamond both are represented as box. box is the default value.

Additional optional parameters:

  • s_size – size of the node. The default size is given by the parameter “Default Area” within the PajekNetGraphGeneratorImpl dialog in STEM. For STEM the size of the node is not limited. Overlaps of nodes are not checked by the importer, they are allowed.
Example: 1 ”vertex one” 0.3456 0.1234 0.5 ellipse s_size 0.1

Parameters only valid in STEM (these parameters are ignored by Pajek):

  • popid – identifier of a population of the node. This parameter may be used repeatedly.
  • popcount – number of individuals living in the node. This parameter may be used repeatedly. The associated popid is the last mentioned one.
Example: 1 ”vertex one” 0.3456 0.1234 0.5 ellipse s_size 0.1 popid human popcount 24 popid anopheles popcount 1000

2. *Edges

The keyword "*Edges" is the starting point for the edges section. Each edge is described using the following format:

v1 v2 [borderlength] [additional optional parameters]

  • v1 – initial vertex number. The definition of v1 is obligatory. v1 has to be defined as node (see above: vertexnum).
  • v2 – terminal vertex number. The definition of v2 is obligatory. v2 has to be defined as node (see above: vertexnum).
  • borderlength – defines the borderlength for CommonBorderEdges

Additional optional parameters:

Parameters only valid in STEM (these parameters are ignored by Pajek):

  • popid – identifier of a population migrating on the edge. This parameter may be used repeatedly. If this parameter and additionally “rateab” or “rateba” is set at least once then a MigrationEdge will be specified in STEM, otherwise a CommonBorderEdge will be defined.
  • rateba – fraction of the population in node v2 migrating over the edge to the node v1 in a given time period. This parameter may be used repeatedly. The associated popid is the last mentioned one. The default value is 0.
Example: 1 2 popid human rateab 0.2 rateba 0.1 popid anopheles rateab 0.5 rateba 0.1

3. *Arcs

The keyword "*Arcs" is interchangeable with "*Edges".

Example files

In the downloadable project, you will find some examples that may be imported into STEM:


The filename extension ".net" is not mandatory.

Back to the top