Maximum order of triangle-free graphs with a given rank

Here is the source code to generate maximum order non-bipartite triangle-free graphs with a given rank. For details, take a look at

E. Ghorbani, A. Mohammadian and B. Tayfeh-Rezaie, Maximum order of triangle-free graphs with a given rank. (pdf)