SOLUTIONS

MATHEMATICA IMPORT/EXPORT FORMAT
GraphML (.graphml)
GraphML graph data format.
Standard exchange for graphs.
GraphML is an acronym derived from Graph Markup Language.
XMLbased format.
Represents typed, attributed, directed, and undirected graphs.
Can also store nested graphs and hypergraphs.
Supports userdefined edge and vertex types.
Proposed by the GraphML working group in 2001.
Standard exchange for graphs.
GraphML is an acronym derived from Graph Markup Language.
XMLbased format.
Represents typed, attributed, directed, and undirected graphs.
Can also store nested graphs and hypergraphs.
Supports userdefined edge and vertex types.
Proposed by the GraphML working group in 2001.
Import and ExportImport and Export
 Import["file.graphml"] imports the graphs stored in the specified file, given as a single Graph object or a list of graphs.
 Export["file.graphml", expr] exports an adjacency matrix or edge information for one graph or for multiple graphs to the GraphML format.
 Import["file.graphml", elem] imports the specified element from a GraphML file.
 Import["file.graphml", {elem, sub_{a}, sub_{b}, ...}] imports a subelement.
 Import["file.graphml", {{elem_{1}, elem_{2}, ...}}] imports multiple elements.
 The import format can be specified with Import["file", "GraphML"] or Import["file", {"GraphML", elem, ...}].
 Export["file.graphml", expr, elem] creates a GraphML file by treating expr as specifying element elem.
 Export["file.graphml", {expr_{1}, expr_{2}, ...}, {{elem_{1}, elem_{2}, ...}}] treats each as specifying the corresponding .
 Export["file.graphml", expr, opt_{1}>val_{1}, ...] exports expr with the specified option elements taken to have the specified values.
 Export["file.graphml", {elem_{1}>expr_{1}, elem_{2}>expr_{2}, ...}, "Rules"] uses rules to specify the elements to be exported.
 See the reference pages for full general information on Import and Export.
 ImportString and ExportString support the GraphML file format.
ElementsElements
 General Import elements:

"Elements" list of elements and options available in this file "Rules" full list of rules for each element and option "Options" list of rules for options, properties, and settings  Data representation elements:

"AdjacencyMatrix" edge information, given as a list of matrices "EdgeAttributes" edge attributes, represented as a list of rules "EdgeLabels" list of strings representing edge labels "EdgeRules" connectivity data for all graphs, given as an array of rules "Graph" first graph stored in the file, given as a Graph object "Graphics" first graph stored in the file, rendered as a graph plot "GraphicsList" all graphs given as a list of graphics objects "GraphList" all graphs stored in the file, given as a list of Graph objects "VertexAttributes" vertex attributes, represented as a list of rules "VertexCount" number of vertices in each graph, given as a list of integers "VertexList" vertices, given as a list of strings  Import by default uses for simple GraphML files and for multigraph GraphML files.
 Element specifications for GraphML files containing multiple graphs:

"GraphNames" names of the graphs, given as a list of strings elem,"name" element elem for the graph specified by elem,n data representation element elem for the n graph in this file elem,{n_{1},n_{2},...} element elem for graphs , , ... elem,All element elem for all graphs, given as a list
OptionsOptions
 General Import options:

ImageSize Automatic specifies the overall size of the image to display for a graph  When importing from GraphML, all options supported by Graph can be given. Common settings include:

EdgeLabels Automatic labels and label placement for edge EdgeWeight Automatic weight for edge VertexCoordinates Automatic center coordinate for vertex VertexLabels Automatic labels and label placement for vertex VertexShape Automatic graphic shape for vertex  When importing , all options supported by GraphPlot can be given. Common settings include:

DirectedEdges Automatic whether to show edges as directed arrows EdgeLabeling Automatic whether to include labels given for edges EdgeRenderingFunction Automatic function to give explicit graphics for edges VertexLabeling Automatic whether to show vertex names as labels VertexRenderingFunction Automatic function to give explicit graphics for vertices  When exporting from a Graph object, Mathematica graph attribute values are often exported as strings using Compress.
ExamplesExamplesopen allclose all
Basic Examples (7)Basic Examples (7)
Import a graph from a GraphML file:
In[1]:= 
Out[1]= 
Export a Graph object to GraphML:
In[1]:= 
Out[1]= 
In[1]:= 
Out[1]= 
Import a graph from the exported file:
In[2]:= 
Out[2]= 
Show the Import elements available in an example file:
In[1]:= 
Out[1]= 
Import edge and vertex labels and the connectivity rules from this file:
In[1]:= 
Out[1]= 
Import as a Graph object:
In[1]:= 
Out[1]= 
Import the edge attributes in an example file:
In[1]:= 
Out[1]= 
Import and plot a graph, displaying vertex labels:
In[1]:= 
Out[1]= 
New in 8
Mathematica 9 is now available!
New to Mathematica?
Find your learning path »
Have a question?
Ask support »