(Nooy, Mrvar, & Batagelj, 2011) is a software tool for analyzing social networks.
Pajek was developed to support the analysis of very large networks (Batagelj & Mrvar,
1998), as well as the visualization of networks (Batagelj & Mrvar, 2003). Pajek is used
by thousands of network researchers in many countries. Recently, textbooks in Japanese
(Nooy, Mrvar, Batagelj, &
, 2009) and Chinese (Nooy, Mrvar, & Batagelj, 2012)
Researchers are used to handling their data in statistical tool, spreadsheet programs, or
databases. A crucial pre-condition for analyzing networks is to convert network data into
network files that can be read by network tools. This is the purpose of txt2Pajek. In this
tech report, we describe how to use txt2Pajek to convert data stored in text files to Pajek
network files. We first review the basics of the Pajek data format and the format of the
text files that can be used as input for txt2Pajek. Then, we describe the basic process of
converting text files to Pajek files by using txt2Pajek. Finally, advanced options are
explored to create Pajek files with additional information (e.g. link labels, temporal
information, multi-relational networks, vectors, partitions).
1.1 Pajek Data Format
Pajek works with a rather easy and straightforward approach in handling data files. It is
important to know that all Pajek files are plain text files that can be read with any text
tools. However, you should not use “advanced” text tools like Microsoft Word and the
like that add formatting information to the text file. Instead, use regular text editors (e.g.
Textpad, or BabelPad for Unicode files).
Figure 1: Pajek file format. Left: .net network file. Center: .clu partition file.
Right: .vec vector file.
Most of your activities in Pajek will result in one or more of these three data objects:
networks, partitions, and vectors. We do not discuss other data objects in this document
but you can find more about all data objects in the Pajek manual
. Networks, vectors, and
partitions are stored in different file formats that Pajek can read and write. Figure 1 shows
examples for these three file formats. In contrast to other SNA tools, Pajek stores files in
In Slovenian language Pajek means spider.
plain text format. This has several advantages. First, readability; the files can be opened
and modified in any text editor. Second, compatibility; files can be exchanged between
Pajek and other tools quickly and in both directions. Third, it is easy to create files that
Pajek can read from other tools.
1.2 Format of Text Files for txt2Pajek
txt2Pajek works with regular text files. Most tools (e.g. Microsoft Excel) or databases
have the ability to export data in this format. Look for tabulator separated text files .txt or
.tab. Comma separated or any other text format is possible, however, we highly
recommend tab-separated files. Avoid working with advanced text processing tools (e.g.
Microsoft Word) as these files have additional formatting and other meta-information
stored in the file. A typical text file that serves as input for txt2Pajek looks like what is
shown in the left part of Figure 2. You can see three columns, two for node information
and one column describing the link weights. We call this format edge list, as every line
describes a single edge in the network. Independently from the complexity of your data,
the basic form of one edge by line must be guaranteed, e.g.:
from to weight link.color link.type time etc…
This approach results in additional columns in the text file for additional information.
That is the reason why the txt2Pajek user interface consists of many dropdown objects
which are used to assign a column from the text file to a specific network attribute. In our
simple example, the text file consists of three columns and four lines (without the header
line) with different values. These lines can be seen in the Pajek file (Figure 2 center) and
in the network picture of on the right of Figure 2. Please note that there is no definition of
nodes in this text file. Nodes are implicitly defined as they are part of links.
1 2 1
2 3 3
3 4 4
1 3 3
Figure 2: edgelist.txt (left) and the resulting Pajek file (center) with four nodes and
four edges as well as the network visualization (right).
2 Basic Functionality
txt2Pajek 3 has more features than previous versions. To reduce the complexity of the
tool, there are two layers of options (see tabs in Figure 3), basic options and advanced
options. In the following we discuss the basic options. On top of the tool you can find
three buttons. “Run” starts the conversion process, “Info” shows tool information and the
link to the related web page, “Exit” quits the program.
Figure 3: The basic functionalities highlighted in the txt2Pajek 3 main window.
Beside the many options that you have, txt2Pajek makes some decisions on handling your
text files without giving you the option to change it:
Multiple lines stay multiple lines. If your input data has multiple lines from A to
B, then your .net file will have the same number of multiple lines. You can
aggregate these multiple lines later in Pajek if you want.
If there are any quotation marks ("), they will be removed from the text. This is
important as Pajek uses quotation marks to indicate beginning and ending of text
and additional quotation marks would create errors when loading the file in Pajek.
The first thing you do when starting txt2Pajek is select an input file. You can also select
multiple input files in the file open dialog by pressing the Shift or the Ctrl key while
selecting files with the mouse. The output file gets set automatically to the same path and
filename as the input file but with a .net extension indicating a network file in Pajek
format. You can change the name of the output files manually.
Every text file needs a separator that indicates the separations of different column
information. txt2Pajek offers four pre-defined separator, tabulator, comma, semi-colon,
and space (blank). By selecting other, you can use any character or combination of
characters as separator. However, we strongly recommend using tabulators as separators
as all other characters could be part of your data. As a matter of fact, mixing values with
separators is a common error, e.g.
will result in an error as the additional comma in Joe’s line cannot be interpreted
correctly; “The” is not valid for a link value.
The text field next to “Preview:” tells you whether your separator selections work or not.
“___” is used to indicate the separator. For instance, if the first line in your text file is
“nameA,nameB” and “comma” is selected as separator then the preview will show
“nameA___nameB”. If “other” is selected and “a” is added as other separator, then
“n___meA,n___meB” is the result. Selecting the right separator is crucial for txt2Pajek in
order to identify the columns correctly that also appear as values in the dropdown objects
of the GUI.
A link in a network is described by two essential pieces of information, a source and a
sink node. Every link connects two nodes. The columns with these nodes are selected
with the two dropdowns “1
Column” and “2
Column”. The third dropdown selects the
link values. This selection is optional. If your network is not weighted (no different
values for links) then “1” is selected to add the value 1 for every link in the network.
For the “Network Type” there are three different options to select. For one mode
networks there are two different options, either directed (arcs) or undirected (edges). Two
mode networks are undirected:
a) 1-mode undirected (*Edges):
b) 1-mode directed (*Arcs):
c) 2-mode undirected (*Edges):
The option “Header Lines” is used to tell txt2Pajek how many lines from top of the text
file should be ignored because they include header information and not network
information. For the example in Figure 2, we would select “1” as the first line should not
be included to create the network file.
The info window can be seen as protocol. Information about the created networks and
error messages are written here.
3 Advanced Options
Advanced options can be found on the “Advanced” tab. The options describe additional
line information, optional partition and vector files as well as additional options related to
the text file or the network type.
Figure 4: Overview of advance features.
3.1 Other Line Info
With “other line info” some advanced options are possible. The underlying logic is the
prefix line info suffix
You can use this to code any additional information for lines. For instance, if <column>
represents the column selections of the dropdown of line info 1 or line info 2, then these
are possible examples for prefix/line info/postfix combinations:
for line colors
for line labels
for temporal information
3.2 Vector/Partition Files
One of the new features of txt2Pajek 3 are the options to create vector and partition files
during the network creation process. In Pajek, partitions are used to split nodes into non-
overlapping groups based on a nominal variable, e.g. gender, nationality, department, etc.
Vectors are used to store quantitative information of nodes, e.g. salary, size, etc. as well
as centrality metrics. The edge list logic of txt2Pajek has two implications for
incorporating vector and partition information (see Figure 5). First, we need two columns
for the information, one for each node column. For this example we select “genderA” for
column and “genderB” for 2
column. Second, vector and partition information need
to be redundant as normally nodes occur in more than one line. You can see that Susan is
twice in the text file and her partition information occurs twice, too
. Of course, this can
be a painful task if you prepare your text file by hand, but when the data is exported from
a database, this should not be a problem.
1 2 1
2 3 1
3 4 1
Figure 5: Text file to create a network and a partition file (left)
and the resulting network (center) and partition (right) file.
3.3 Allow Loops
A loop is a link from a node to itself. The example in Figure 6 shows that “wei” is
connected to “wei”. Loops are special in network analysis and it is important to be aware
of whether your data has loops or not – creating a network with loops should be an
explicit decision. Consequently, we added the option “Allow Loops” that is not selected
by default. txt2Pajek always checks for loops and you will get an error message if your
data contains a loop and this option is unselected.
Technically, the partition or vector information gets assigned when a node occurs for the first time.
Figure 6: Illustrating loops in text files.
3.4 Allow Empty Cells
Empty cells can be the result of data errors. If your data has an empty cell the conversion
process stops and no file is created. But there are cases for which empty cells are
tolerated or even necessary. The main purpose of empty cells is to include nodes to the
networks that have no links (isolates). As the link list format just includes nodes that are
part of links, an empty cell in the link list is the only way of including isolates to a
network file. In Figure 7 you can see that “Marc” is not connected to a city. The option
'allow empty cells' creates a “*UNKNOWN*” vertex (in case of 2-mode:
“*UNKNOWN1*” and “*UNKNOWN2*”). You can delete these nodes later in Pajek;
then Marc will be an isolate.
*Vertices 9 5
1 6 1
2 7 1
2 8 1
3 8 1
4 7 1
5 8 1
3 9 1
Figure 7: Empty cells in the text files (left) and the resulting network file (right).
3.5 UTF-8 Unicode
UTF-8 is a code format that incorporates special characters from many languages
(including Japanese and Chinese, see Figure 8). Another term that is used instead of
UTF-8 is “Unicode”. Regular text editors often do not use Unicode. If you open a UTF-8
file in those editors you get a warning message that UTF-8 characters are getting
destroyed. There are special Unicode editors that overcome this problem, e.g. BabelPad,
XPad, jEdit. The most important thing is that your editor should be capable of saving text
files as “UFT-8 with Byte Order Mark” or BOM. This is the Unicode format of Pajek.
Figure 8: Pajek unicode network from the Pajek manual
3.6 Multi-Relational Networks
One network can have different groups of lines. For instance, two nodes can be “friends”
while two other nodes are “colleagues”. You can create different networks for every type
of links but you can also create one network that incorporates different link types. This is
called a multi-relational network in Pajek. For txt2Pajek it is necessary to code this
information in an additional column (see Figure 9).
*Edges :1 "colleague"
3 1 1
5 6 1
*Edges :2 "no relation"
6 3 1
*Edges :3 "friends"
1 2 1
2 3 1
3 4 1
Figure 9: Multi-relational network. Text file (left) and
resulting Pajek network file (right).
Many people have been using txt2pajek in the last 10 years. Some of them gave
important feedback that helped to further develop the tool. We would like to thank all of
them and especially the large Pajek community. For creating txt2Pajek 3 Weiqi Cai from
Documents you may be interested
Documents you may be interested