# Question:How can we convert between mtx-format and graph-format?

## Question:How can we convert between mtx-format and graph-format?

Maple 2023

There are various variants of graph coloring, such as when I want to compute the star chromatic number of a graph, Maple (or Mathematica) seems not to provide relevant functions.

Fortunately, the software ColPack   offers this functionality （Note: I just noticed that this software also uses greedy coloring instead of accuracy）. However, it supports the MTX format. So, the question is:

•  How can I write a graph in MTX format?

And

•  how can the MTX format be converted into a graph format?

Of course, I would like to perform these operations in Maple.  (SageMath may have something)

The following is an example (bcsstk01.mtx） in the directory `ColPack-master/Graphs directory` of the source code of ColPack.

bcsstk01.mtx.txt

```./ColPack -f ../../Graphs/bcsstk01.mtx -m STAR
Out: 11```

But I do not know what the graph in the example is. On the contrary, I would like to compute the star chromatic number of the Petersen graph, and I also don't know how to convert it into the MTX format like the above.

```with(GraphTheory):
with(SpecialGraphs):
P:=PetersenGraph()```

I don't understand what the very long decimal numbers (like `2.8322685185200e+06`) in the third column in the MTX-file. Will it affect the  imformation of the entire graph?

For MTX format, see https://math.nist.gov/MatrixMarket/formats.html.  For graphs, the numbers in the third column can all be considered as 1 (with the first two columns representing vertices, and their adjacency). Of course, this is my interpretation and may not necessarily be correct.

﻿