atlas method

Graph<V, E> atlas(
  1. int number
)

Returns a graph from "An Atlas of Graphs" by Ronald C. Read and Robin J. Wilson, Oxford University Press, 1998. number is a number between 0 and 1252.

The graphs are sorted by the number of nodes, the number of vertices, in increasing order of degree sequence, and in increasing number of automorphisms.

Implementation

Graph<V, E> atlas(int number) {
  final encoded = _atlas[number];
  final builder = newBuilder();
  assert(encoded[0] >= 0, 'Invalid number of vertices');
  for (var i = 0; i < encoded[0]; i++) {
    builder.addVertexIndex(i);
  }
  assert(2 + 2 * encoded[1] == encoded.length, 'Invalid number of edges');
  for (var i = 0, o = 2; i < encoded[1]; i++, o += 2) {
    assert(encoded[o] != encoded[o + 1], 'Invalid edge pair');
    builder.addEdgeIndex(encoded[o], encoded[o + 1]);
  }
  return builder.build();
}