# Reading and writing files

*Graphs.jl* includes functions for working with graphs stored in various file formats/

## Index

`Graphs.loadgraph`

`Graphs.loadgraphs`

`Graphs.loadlg_mult`

`Graphs.savegraph`

`Graphs.savegraph`

`Graphs.savelg`

`Graphs.savelg_mult`

## Full docs

`Graphs.loadgraph`

— Method`loadgraph(file, gname="graph", format=LGFormat())`

Read a graph named `gname`

from `file`

in the format `format`

.

**Implementation Notes**

`gname`

is graph-format dependent and is only used if the file contains multiple graphs; if the file format does not support multiple graphs, this value is ignored. The default value may change in the future.

`Graphs.loadgraphs`

— Method`loadgraphs(file, format=LGFormat())`

Load multiple graphs from `file`

in the format `format`

. Return a dictionary mapping graph name to graph.

**Implementation Notes**

For unnamed graphs the default name "graph" will be used. This default may change in the future.

`Graphs.savegraph`

— Method`savegraph(file, g, gname="graph", format=LGFormat)`

Saves a graph `g`

with name `gname`

to `file`

in the format `format`

. Return the number of graphs written.

**Implementation Notes**

The default graph name assigned to `gname`

may change in the future.

`Graphs.savegraph`

— Method`savegraph(file, g, d, format=LGFormat)`

Save a dictionary of `graphname => graph`

to `file`

in the format `format`

. Return the number of graphs written.

**Implementation Notes**

Will only work if the file format supports multiple graph types.

`Graphs.loadlg_mult`

— Method`loadlg_mult(io)`

Return a dictionary of (name=>graph) loaded from IO stream `io`

.

`Graphs.savelg`

— Method`savelg(io, g, gname)`

Write a graph `g`

with name `gname`

in a proprietary format to the IO stream designated by `io`

. Return 1 (number of graphs written).

`Graphs.savelg_mult`

— Method`savelg_mult(io, graphs)`

Write a dictionary of (name=>graph) to an IO stream `io`

, with default `GZip`

compression. Return number of graphs written.