Multi-Population Pajek Graph Example

This page is about the new Pajek format which is used in STEM releases since version 1.4.0 and in current milestone and integration builds. The old format that was used prior to 1.4.0 is still supported. Examples and documentation of the old format are available at the website download page for Multi-Population Pajek Graph Example.

Create a Pajek file

To create a Pajek file, download and use this ODS spreadsheet document here.
Open the ODS spreadsheet, with LibreOffice [1] and activate the macro element.
Important: To do this, you must be running JRE [2] on your system.

After modifying the spreadsheet, you can export the file as Pajek file.
Please click for this:

File

ExportToPajek (The first option in the opened dialogue)

Save it on your system (it will automatically be saved as a .net file)

It is also possible to open and modify a Pajek file with a text editor, but it is much simpler to use the recommended spreadsheet.

File Format

STEM allows users to create a custom graph using a format similar to the Pajek ([3]) format. The Libre Office spreadsheet produces a .net file that is in the correct format to be imported into STEM via the PajekNetGraphGenerator, which is available in the graph creation dialogue of STEM:

Note: when using a Demographic Population Model in STEM you need only declare the main population name e.g. human in the list of nodes. You can refer to individual population subgroups (e.g., men, women) when declaring the populationID for the edges.

Migration Edges

origin node number – number of the node the population migrates from. Has to be defined as node number in *Vertices.

destination node number – number of the node the population migrates from. Has to be defined as node number in *Vertices.

populationID – defines the ID of the migrating population.

rate - number population members migrating per day.

Optional parameters:

date - specification a of date at which the migration rate is different from the standard value specified in the obligatory parameters. ISO 8601 standard is used (YYYY-MM-DD). This parameter may be used repeatedly.

rate - migration rate for the specified date. This parameter may be used repeatedly. The associated date is the last mentioned one.

Example:

1 2 popID beef rate 1.0 date 2012-01-01 rate 10.0

Note: the optional parameters are not automatically implemented when you use the pajek graph in STEM. They are all specified in a single trigger which will be located in the "Triggers" folder of your project. The name of the trigger usually starts with "List platform:/resource" and ends with the name of your pajek graph. The trigger must be dragged into your scenario in order for the optional parameters to be implemented.

Containment Edges

[containing node number] [contained node number]:

containing node number – number of the node that contains the other node. Has to be defined as node number in *Vertices.

contained node number – number of the node that is contained by the other node. Has to be defined as node number in *Vertices.

To edit the pajek graph in STEM, right-click on the graph and then select "display", as described here [4] and shown below:

Using the dialog

The dialog to import a Pajek graph from a file is shown on the right. It is available in the STEM Graph Dialog. The following parameters are available for importing:

Pajek File - The file from which the graph is imported. A file dialog is available to select the file.

Scaling Factor - A factor by which all coordinates specified in the file are scaled during import. If node has the coordinates 10.0/20.0 in the file and the scaling factor is 2.0, the node's resulting coordinates in STEM are 20.0/40.0.

Node Size - In STEM each imported node appears as a square for visualization. This parameter specifies the edge length of the squares for all imported nodes.

Use global Region Names - If selected, the URIs for the imported nodes will be of the type stem://org.eclipse.stem/node/geo/region/*****. This has the advantage, that the nodes can be accessed by just using that last part of the URI *****. This option should only be used if node names specified in the Pajek file are unique and do not occur in other STEM graphs. If not selected, the node URIs will contain the graph's URI.

Move Nodes to Containers - If selected, all nodes that are contained by another node from a different graph will be moved close to this container. That means that coordinates specified for these nodes in the Pajek file will be ignored.

Use Absolute Migration Rates- If selecting “yes” then the rate will be the exact number of individuals that are moving across migration edges. If selecting “no”, then a rate from 0-1 must be specified to move a proportion of individuals across the migration edge. Note that if a stochastic solver is used, then this will be a probability of movements, rather than an exact proportion.

Tutorial

A tutorial on how to import a Pajek graph that contains discrete migration events for a STEM graph is available at Import Discrete Transportation Events. Discrete events can be used to model commodity flows, e.g., the transportation of beef from slaughterhouses to supermarkets in order to model the spread of a foodborne disease.

Common Errors

If you get an “out of bounds” exception, then it is likely that the numbers in your nodes do not match those used in your edges.
If you are using data from an Excel spreadsheet and copying into the Libre Office spreadsheet, make sure you choose “paste special” > “unformatted code” > “unitext”.

Contributors

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