Graph file format

Graphs are plain text, one item per line:

t 4 4
v 0 1 2
v 1 2 2
v 2 1 2
v 3 2 2
e 0 1
e 1 2
e 2 3
e 3 0
t N M

The number of vertices N and edges M. Informative only: the reader ignores it.

v ID LABEL [DEGREE]

A vertex, its label and optionally its degree (ignored).

e U V

An undirected edge between vertices U and V. Further fields, such as an edge label, are ignored.

This is the format of the SubgraphMatching benchmarks.

Details

  • Vertex IDs and labels are integers that fit in 64 bits. IDs need not be 0..N-1, contiguous or in order.

  • Only lines whose first field is exactly v or e are read; blank and other lines are ignored. Fields are separated by spaces or tabs, and lines may end in \n, \r\n or \r.

  • A repeated edge, in either direction, is kept once, and so is a repeated self-loop. A repeated v line keeps the vertex’s first position and updates its label.

  • A vertex that appears only in edges is added without a label. It matches no labelled pattern vertex.

  • Vertices are ordered with every v line’s vertex first, in file order, then the vertices that appear only in edges, in order of first appearance. A vertex’s neighbours are in order of first appearance. This is the order NetworkX builds from the same file.

  • A v or e line with a missing or non-integer field raises ValueError with the line number.