Maple Professional
Maple Academic
Maple Student Edition
Maple Personal Edition
Maple Player
Maple Player for iPad
MapleSim Professional
MapleSim Academic
Maple T.A. - Testing & Assessment
Maple T.A. MAA Placement Test Suite
Möbius - Online Courseware
Machine Design / Industrial Automation
Aerospace
Vehicle Engineering
Robotics
Power Industries
System Simulation and Analysis
Model development for HIL
Plant Modeling for Control Design
Robotics/Motion Control/Mechatronics
Other Application Areas
Mathematics Education
Engineering Education
High Schools & Two-Year Colleges
Testing & Assessment
Students
Financial Modeling
Operations Research
High Performance Computing
Physics
Live Webinars
Recorded Webinars
Upcoming Events
MaplePrimes
Maplesoft Blog
Maplesoft Membership
Maple Ambassador Program
MapleCloud
Technical Whitepapers
E-Mail Newsletters
Maple Books
Math Matters
Application Center
MapleSim Model Gallery
User Case Studies
Exploring Engineering Fundamentals
Teaching Concepts with Maple
Maplesoft Welcome Center
Teacher Resource Center
Student Help Center
GraphTheory[ImportGraph]
GraphTheory[ExportGraph]
Calling Sequence
ImportGraph(filename, format, output=outform)
ExportGraph(G, filename, format)
ExportGraph(G, filename, format, append)
Parameters
G
-
graph, list of graphs, or graph generating function
filename
string, symbol, or function
format
symbol or string
outform
output format, one of graph, list, or iterator
Description
ImportGraph reads one or more graphs from a file. For a file containing a single graph, the supported formats are `dimacs`, `dimacs_relaxed`, `combinatorica`, `edges`, and `dot`. For a file containing multiple graphs, the supported formats are `sparse6` and `graph6`.
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 a 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`, and `dot`. For exporting multiple graphs to a file, the supported formats are `sparse6` and `graph6`, and these can be mixed in a file (either being valid to specify reading both 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.
Examples
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.
See Also
Graph, read, save
Download Help Document