此为 Mathematica 8 文档,内容基于更早版本的 Wolfram 语言
查看最新文档(版本11.1)

GraphML (.graphml)

GraphML graph data format.
Standard exchange for graphs.
GraphML is an acronym derived from Graph Markup Language.
XML-based format.
Represents typed, attributed, directed, and undirected graphs.
Can also store nested graphs and hypergraphs.
Supports user-defined edge and vertex types.
Proposed by the GraphML working group in 2001.
  • Import imports the graphs stored in the specified file, given as a single Graph object or a list of graphs.
  • Export exports an adjacency matrix or edge information for one graph or for multiple graphs to the GraphML format.
  • Import imports the specified element from a GraphML file.
  • Import imports multiple elements.
  • Export creates a GraphML file by treating expr as specifying element elem.
  • Export treats each as specifying the corresponding .
  • Export exports expr with the specified option elements taken to have the specified values.
  • Export uses rules to specify the elements to be exported.
  • See the reference pages for full general information on Import and Export.
"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 multi-graph 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,ndata representation element elem for the n^(th) graph in this file
elem,{n1,n2,...}element elem for graphs
elem,Allelement elem for all graphs, given as a list
ImageSizeAutomaticspecifies 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:
EdgeLabelsAutomaticlabels and label placement for edge
EdgeWeightAutomaticweight for edge
VertexCoordinatesAutomaticcenter coordinate for vertex
VertexLabelsAutomaticlabels and label placement for vertex
VertexShapeAutomaticgraphic shape for vertex
  • When importing "Graphics", all options supported by GraphPlot can be given. Common settings include:
DirectedEdgesAutomaticwhether to show edges as directed arrows
EdgeLabelingAutomaticwhether to include labels given for edges
EdgeRenderingFunctionAutomaticfunction to give explicit graphics for edges
VertexLabelingAutomaticwhether to show vertex names as labels
VertexRenderingFunctionAutomaticfunction to give explicit graphics for vertices
  • When exporting from a Graph object, Mathematica graph attribute values are often exported as strings using Compress.
Import a graph from a GraphML file:
Export a Graph object to GraphML:
Export graph data to GraphML:
Import a graph from the exported file:
Show the Import elements available in an example file:
Import edge and vertex labels and the connectivity rules from this file:
Import as a Graph object:
Import the edge attributes in an example file:
Import and plot a graph, displaying vertex labels:
Import a graph from a GraphML file:
In[1]:=
Click for copyable input
Out[1]=
 
Export a Graph object to GraphML:
In[1]:=
Click for copyable input
Out[1]=
 
Export graph data to GraphML:
In[1]:=
Click for copyable input
Out[1]=
Import a graph from the exported file:
In[2]:=
Click for copyable input
Out[2]=
 
Show the Import elements available in an example file:
In[1]:=
Click for copyable input
Out[1]=
 
Import edge and vertex labels and the connectivity rules from this file:
In[1]:=
Click for copyable input
Out[1]=
 
Import as a Graph object:
In[1]:=
Click for copyable input
Out[1]=
 
Import the edge attributes in an example file:
In[1]:=
Click for copyable input
Out[1]=
Import and plot a graph, displaying vertex labels:
In[1]:=
Click for copyable input
Out[1]=