g2mtx
Convert from any graph formatto g2mtx Convert from g2mtxto any other format
The Network Graph Toolkit (NGraph Toolkit), sometimes referenced by one of its component programs such as g2mtx, is a collection of over thirty command-line programs, filters, and shell scripts for analyzing large networks represented as mathematical graphs. It was developed at the U.S. National Institute of Standards and Technology (NIST) by Roldan Pozo, a senior research scientist in the Applied and Computational Mathematics Division whose work spans complex networks, high-performance computing, and numerical software (he also authored the Template Numerical Toolkit). As a work of U.S. federal employees, the toolkit and its underlying library are released into the public domain, with the authors requesting only acknowledgement when redistributed.
The toolkit is built on the NGraph C++ library, a deliberately compact (a few hundred lines) STL-based class that models a graph as sets and maps of node pairs, with nodes represented as non-negative integers. It maintains an adjacency-list-style structure for efficient neighbor lookup and exposes a small, teachable API (insertedge, removeedge, containsedge, degree, outneighbors) plus STL-style iterators. NGraph is fundamentally a directed-graph library that simulates undirected graphs by storing only edges where i < j, and it prohibits self-loops and multiple edges. Its author is explicit that it is not a replacement for heavyweight packages such as Boost Graph Lib's Boost Graph Library or LEDA, and it targets small-to-medium graphs.
Where the toolkit is most relevant to format conversion is its family of translator utilities. Its native format is a simple edge list (.g, with .gu/.gd directed/undirected and .gs string-labeled variants) closely aligned with Edge List and Adjacency List conventions. Dedicated programs convert to and from other representations: g2mtx and mtx2g bridge the native format and Matrix Market sparse-matrix files, g2dot emits DOT for Graphviz, and importers/exporters cover Pajek (.net), GDF (Guess), and GraphML. Additional programs compute degree distributions, clustering coefficients, community labels, and subgraphs.
In practice NGraph occupies a niche as a lightweight, Unix-pipeline-friendly workbench for network-science preprocessing and statistics, useful for translating between matrix and graph encodings and computing basic topological measures. Its strengths are simplicity, scriptability, and permissive licensing; its limitations are the plain integer-vertex model, the ban on loops and multi-edges, the assumption of no isolated vertices in the standard .g format, and the need to stitch stand-alone tools together with scripts for complex workflows. It has seen little recent development and lacks the ecosystem of NetworkX or igraph.
Output Formats
Frequently Asked Questions
What graph file formats does g2mtx support?
See the list on this page — it shows every format g2mtx can read, write and display.
How do I import a graph into g2mtx?
Convert your file to a format g2mtx can read, then open it in g2mtx. Use GraphInOut to get a g2mtx-compatible file in seconds.
How do I convert a file so g2mtx can open it?
Use the convert links above — upload or paste your graph, pick a format g2mtx accepts and download the result, right in your browser.