Skip to content

graph-io ​

graph-io reads and writes graph files. It turns a GraphML, GEXF, CSV or other graph file into a @graphty/graph-format snapshot, and writes a snapshot back out in any of the same formats. It runs in browsers and in Node, and streams large files. Its one dependency, graph-format, is installed with it.

When a file holds something graph-io cannot represent, or a format cannot hold part of your graph, graph-io tells you: an import returns a report that lists every skipped or changed element, and checkExport() lists what a save would lose before you write a byte.

bash
npm install @graphty/graph-io

Start with the Quick start.

Formats ​

FormatWhat it is
JSONNetworkX, d3, JSON Graph Format, Cytoscape.js, graphology, vis.js and OBO Graphs documents
GraphMLThe XML format of yEd, NetworkX, igraph and Gephi
GEXFGephi's XML format, with visual attributes and dynamic graphs
CSV and TSVEdge lists, node tables and adjacency lists from spreadsheets and scripts
GMLThe Graph Modelling Language, as NetworkX and igraph write it
DOTGraphviz graphs
PajekPajek .net networks and .paj projects
Neo4j CSVThe CSV files neo4j-admin import reads
XGMMLCytoscape's XML network format
CX2The JSON exchange format of NDEx and Cytoscape 3.10 and later
CXVersion 1 of the same exchange format
OBOThe ontology format of the Gene Ontology and the OBO Foundry
Cytoscape sessionCytoscape Desktop .cys files

graph-io reads and writes all of them. All formats compares what each one keeps.

Where to go next ​

If you display graphs with graphty-element, you already use graph-io: element.loadFromUrl() and element.loadFromFile() read files through it. Use graph-io directly when you want the graph data yourself, for example to convert files, analyze a graph, or draw it with your own renderer.