Pajek (.net)

Background & Context

    • Pajek graph language and data format.
    • Commonly used exchange format for graphs.
    • Native format of the Pajek network analysis software.
    • The format name is Slovenian for spider.
    • Stores a single directed, undirected, or mixed graph.
    • Can contain user-defined edge and vertex attributes.
    • Plain text format.
    • Developed in 1996 by researchers at Ljubljana University.

Import & Export

  • Import["file.net"] gives a Graph object representing the graph stored in the specified file.
  • Export["file.net",expr] exports an adjacency matrix or edge information representing a graph to the Pajek format.
  • Import["file.net"] imports the graph from file and returns it as a Graph.
  • Import["file.net",elem] imports the specified element from a Pajek file.
  • Import["file.net",{{elem1,elem2,}}] imports multiple elements.
  • The import format can be specified with Import["file","Pajek"] or Import["file",{"Pajek",elem,}].
  • Export["file.net",expr,elem] creates a Pajek file by treating expr as specifying element elem.
  • Export["file.net",{expr1,expr2,},{{elem1,elem2,}}] treats each expri as specifying the corresponding elemi.
  • Export["file.net",expr,opt1->val1,] exports expr with the specified option elements taken to have the specified values.
  • Export["file.net",{elem1->expr1,elem2->expr2,},"Rules"] uses rules to specify the elements to be exported.
  • See the following reference pages for full general information:
  • Import, Exportimport from or export to a file
    CloudImport, CloudExportimport from or export to a cloud object
    ImportString, ExportStringimport from or export to a string
    ImportByteArray, ExportByteArrayimport from or export to a byte array

Import Elements

  • General Import elements:
  • "Elements" list of elements and options available in this file
    "Summary"summary of the file
    "Rules"list of rules for all available elements
  • Data representation elements:
  • "AdjacencyMatrix"edge information, given as a matrix
    "EdgeAttributes"edge attributes, represented as a list of rules
    "EdgeRules"connectivity data for the graph, given as a list of rules
    "EdgeRulesDirected"directed edges
    "EdgeRulesUndirected"undirected edges
    "Graph"graph stored in the file, given as a Graph object
    "Graphics"graph stored in the file, rendered as a graph plot
    "VertexAttributes"vertex attributes, represented as a list of rules
    "VertexCount"number of vertices in the graph
  • Import by default uses the "Graph" element when importing from Pajek.

Options

Examples

Basic Examples  (6)

Import a Graph object from a Pajek file:

Show the Import elements available from an example file:

Import the connectivity rules of a graph:

Export a Graph to the Pajek format:

Export an asymmetric adjacency matrix of a graph to the Pajek format:

Convert a list of edge rules representing an undirected graph to the Pajek language: