import graphs from a file
export graphs to a file
ImportGraph(filename, format, out)
ExportGraph(G, filename, format)
ExportGraph(G, filename, format, append)
graph, list of graphs, or graph generating function
string, symbol, or function
symbol or string
equation of the form output = graph or list, or iterator
ImportGraph reads one or more graphs from a file. For a file containing a single graph, the supported formats are dgml, dimacs, dimacs_relaxed, combinatorica, dot, edges, gexf, graphlet, graphml, gxl, jgf, leda, pajek, tgf, and tsplib. For a file containing multiple graphs, the supported formats are digraph6, graph6, and sparse6. These formats encode the graph in ascii text and are much more compact than the other formats.
The list and iterator output forms only apply to the case of a file with multiple graphs. The list output form returns a list of all graphs in the file, and the iterator output form returns a procedure that generates all the graphs in the file one at a time.
For the iterator, the returned procedure called with no arguments simply outputs the next graph, returning FAIL after the final graph in the file has been output.
Note: The list of graphs and graph generating function forms for G only apply to the multiple graph per file formats.
ExportGraph writes one or more graphs to a file using the specified format. For exporting a single graph to a file, the supported formats are dimacs (only for undirected unweighted graphs), combinatorica (only for undirected unweighted graphs), edges (only for undirected unweighted graphs), metapost, dgml, dot, gexf, graphlet, graphml, gxl, jgf, leda, pajek, and tgf. For exporting multiple graphs to a file, the supported formats are digraph6, graph6, and sparse6, and these can be mixed in a file (any of these being valid to specify reading any of these formats).
The literal append specifies that the graph(s) should be appended to the specified file, while by default the file is simply overwritten.
To export a graph in Maple's format, use the save command. This saves the entire Maple data structure to a file, including vertex positions (used for drawing) and highlighted vertices. To read it back in later, use the read command.
This creates the file "K4" in the current working directory (see currentdir). The file looks like this
1 2 1 3 1 4 2 3 2 4 3 4
The first integer 4 is the number of vertices. The second integer 6 is the number of edges. This is followed by the edges on multiple lines with more than one edge per line. To read the graph back into Maple you would do
P≔Graph 1: an undirected unweighted graph with 10 vertices and 15 edge(s)
File "Graph1.mp" created in metapost format
This creates the file "Graph1.mp" in the current working directory (see currentdir). In Unix, the "mpost" command can then be used to convert a metapost file to PostScript, for inclusion in a LaTeX document.
We have highlighted the star in the Petersen graph and saved it to a file "petersen.txt" in the current working directory. When the file is read, the graph will be reloaded (in the variable P) with the highlighting intact.
The GraphTheory[ImportGraph] and GraphTheory[ExportGraph] commands were updated in Maple 2018.
The format parameter was updated in Maple 2018.
Download Help Document
What kind of issue would you like to report? (Optional)