# Cannot read DIMACS files

**URL:** <https://igraph.discourse.group/t/cannot-read-dimacs-files/1832>\
**Category:** Usage\
**Tags:** Python\
**Created:** [20 July 2024 17:40 UTC](https://igraph.discourse.group/t/cannot-read-dimacs-files/1832 "2024-07-20T17:40:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jfrickmann](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/jfrickmann/32/1087_2.png) [@jfrickmann](https://igraph.discourse.group/u/jfrickmann)\
**Post date:** [20 July 2024 17:40 UTC](https://igraph.discourse.group/t/cannot-read-dimacs-files/1832/1 "2024-07-20T17:40:41Z")

</div>

I am trying to read graphs from the DIMACS archive via Python, but all I get is the error

```auto
igraph._igraph.InternalError: Error at src/io/dimacs.c:286: Unknown line type in DIMACS file. -- Parse error

```

I downloaded the .b graph files from [Index of /pub/challenge/graph/benchmarks/clique (rutgers.edu)](http://archive.dimacs.rutgers.edu/pub/challenge/graph/benchmarks/clique/).

I cannot attach an example because I’m new here 😐, but try e.g. [http://archive.dimacs.rutgers.edu/pub/challenge/graph/benchmarks/clique/brock200\_1.clq.b](http://archive.dimacs.rutgers.edu/pub/challenge/graph/benchmarks/clique/brock200_1.clq.b)

I don’t know if it’s because the binary .b format is incompatible? If anyone has a suggestion for how I can use these files from Python, I will be eternally grateful!

---

<div class="post-metadata">

**Author:** ![szhorvat](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/szhorvat/32/3_2.png) [@szhorvat](https://igraph.discourse.group/u/szhorvat)\
**Post date:** [20 July 2024 20:00 UTC](https://igraph.discourse.group/t/cannot-read-dimacs-files/1832/2 "2024-07-20T20:00:01Z")

</div>

No, this format is not supported by igraph. You will have the implement your own reader, which shouldn’t be too difficult. The DIMACS challenges typically choose formats which are easy to parse (for as long as you don’t need to do error checking).

Generally, there isn’t really a a single “DIMACS format”. Different challenges used different formats, which are similar to each other, but not identical and difficult (or impossible) to interpret in a common framework. What igraph supports is the format for max flow problems. We have an open issue for implementing a more general reader, but doing so is a lot of work (there’s no format specification), and it’s unlikely to happen in the foreseeable future. [General DIMACS importer/exporter · Issue #1924 · igraph/igraph · GitHub](https://github.com/igraph/igraph/issues/1924) The format you link to doesn’t even fit in this, it’s a completely different binary format.

In short, the good news is that all these formats are easy to implement readers for for as long as you focus on reading files from one specific dataset and you don’t attempt error checking. I suggest you do that.

---

<div class="post-metadata">

**Author:** ![jfrickmann](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/jfrickmann/32/1087_2.png) [@jfrickmann](https://igraph.discourse.group/u/jfrickmann)\
**Post date:** [21 July 2024 00:57 UTC](https://igraph.discourse.group/t/cannot-read-dimacs-files/1832/3 "2024-07-21T00:57:50Z")

</div>

I see - thank you for the prompt answer!

The description that I can find seems to be for a text-based format, but the files in the archive seem to have some lines of text followed by binary data. does anyone know where I can find a description of that format with the .b extension?

---

<div class="post-metadata">

**Author:** ![szhorvat](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/szhorvat/32/3_2.png) [@szhorvat](https://igraph.discourse.group/u/szhorvat)\
**Post date:** [21 July 2024 06:37 UTC](https://igraph.discourse.group/t/cannot-read-dimacs-files/1832/4 "2024-07-21T06:37:07Z")

</div>

See here: [Index of /pub/challenge/graph/translators/binformat](http://archive.dimacs.rutgers.edu/pub/challenge/graph/translators/binformat/)
