CMR  1.3.0
File Formats

Matrix File Formats

There are two accepted file formats for matrices.

Dense Matrix

The format dense is a text format in which a matrix \( A \in \mathbb{Z}^{m \times n} \) is represented as a whitespace-delimited list of \( m \), \( n \), and the \( m \cdot n \) entries \( A_{1,1} \), \( A_{1,2} \), etc.. The matrix \( A = \begin{pmatrix} 1 & -1 & 0 \\ 0 & 1 & 1 \end{pmatrix} \) is represented as follows:

2 3

1 -1 0
0  1 1

Sparse Matrix

The format sparse is a text format in which a matrix \( A \in \mathbb{Z}^{m \times n} \) with \( k \) non-zeros are represented as a whitespace-delimited list of \( m \), \( n \), \( k \) and \( k \) triples \( (r,c,v) \) for each nonzero value \( v \) in row \( r \) and column \( c \). Note that \( r \in \{1,2,\dotsc,m\} \) and \( c \in \{1,2,\dotsc,n\} \). The matrix \( A = \begin{pmatrix} 1 & -1 & 0 \\ 0 & 1 & 1 \end{pmatrix} \) is represented as follows:

2 3 4

1 1 1
1 2 -1
2 2 1
2 3 1

Graph File Formats

Currently, graphs can only be specified by means of edge lists.

Edge List

The format edgelist is a text format in which a graph \( G = (V,E) \) is represented as a line-separated list of edges. The line for each edge contains two or three tokens, separated by whitespace. The first two are names of nodes and the optional third specifies a row/column element. The graph \( G = (V,E) \) with nodes \( V = \{v,x,y,z\} \) and edges \( E = \{ \{v,x\}, \{v,y\}, \{v,z\}, \{x,y\}, \{y,z\}, \{z,x\} \} \), labeled as \( r_1, r_2, r_3, c_1, c_2, c_3 \), respectively, is represented as follows:

v x r1
v y r2
v z r3
x y c1
y z c2
z x c3

Row/column element labels are useful for Graphic / Cographic / Planar Matrices. In fact, the format represents a digraph, which is useful for Network Matrices.

Dot

The format dot is a text format for drawing graphs, e.g., via the GraphViz toolbox. See here for the language specification.