Graphlet (.gml)
Background & Context
-
- Graphlet GML graph data format.
- Used for the storage and exchange of graphs.
- GML is an acronym derived from Graph Modeling Language.
- Native format of the Graphlet graph editor software.
- Stores attributed, directed, and undirected graphs.
- Can contain user-defined graph, edge, and vertex attributes.
- ASCII format.
- Developed in 1995.
Import & Export
- Import["file.gml"] imports the graph stored in the specified file, given as a single Graph object.
- Export["file.gml",expr] exports an adjacency matrix or edge information for one graph to the Graphlet GML format.
- Import["file.gml",elem] imports the specified element from a Graphlet GML file.
- Import["file.gml",{elem,suba,subb,…}] imports a subelement.
- Import["file.gml",{{elem1,elem2,…}}] imports multiple elements.
- The import format can be specified with Import["file","Graphlet"] or Import["file",{"Graphlet",elem,…}].
- Export["file.gml",expr,elem] creates a Graphlet GML file by treating expr as specifying element elem.
- Export["file.gml",{expr1,expr2,…},{{elem1,elem2,…}}] treats each expri as specifying the corresponding elemi.
- Export["file.gml",expr,opt1->val1,…] exports expr with the specified option elements taken to have the specified values.
- Export["file.gml",{elem1->expr1,elem2->expr2,…},"Rules"] uses rules to specify the elements to be exported.
- See the following reference pages for full general information:
-
Import, Export import from or export to a file CloudImport, CloudExport import from or export to a cloud object ImportString, ExportString import from or export to a string ImportByteArray, ExportByteArray import from or export to a byte array
Import Elements
- General Import elements:
-
"Elements" list of elements and options available in this file "Summary" summary of the file "Rules" list of rules for all available elements - Data representation elements:
-
"AdjacencyMatrix" edge information, given as a matrix "EdgeAttributes" edge attributes, represented as a list of rules "EdgeRules" connectivity data for the graphs, given as a list of rules "Graph" graph stored in the file, given as a Graph object "GraphAttributes" graph attributes, represented as a list of rules "Graphics" graph stored in the file, rendered as a graph plot "VertexAttributes" vertex attributes, represented as a list of rules "VertexCount" number of vertices in the graph "VertexList" vertices, given as a list of strings - Import by default uses the "Graph" element when importing from Graphlet GML.
Options
- General Import options:
-
ImageSize Automatic specifies the overall size of the image to display for a graph - When importing from GML, 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 as "Graphics", all options supported by GraphPlot can be given. Common settings include:
-
DirectedEdges Automatic whether to show edges as directed arrows EdgeLabels Automatic whether to include labels given for edges EdgeShapeFunction Automatic function to give explicit graphics for edges VertexLabels Automatic whether to show vertex names as labels VertexShapeFunction Automatic function to give explicit graphics for vertices - Export option:
-
DirectedEdges Automatic whether the data to be exported represents a directed graph - When exporting from edge rules or from a symmetric adjacency matrix, edges are taken to be undirected by default.
- When exporting a Graph object, Wolfram Language graph attribute values are often exported as strings using Compress.
Examples
open allclose allBasic Examples (7)
Import a graph from Graphlet GML, rendered as a Graph object:
Import a vertex list and vertex attributes:
Show vertex labels and arrowheads in the graph plot:
Export a Graph object to GML:
Export a list of edge rules representing a directed graph to GML:
Export an asymmetric adjacency matrix of the same graph represented in the above example to GML:
Render an adjacency matrix representation of a Graphlet GML graph as MatrixPlot:
Scope (5)
Construct a list of vertex labels and their attributes in the form of rules:
Convert the first graph stored in a Sparse6 file to a Graphlet GML file:
Generate a Graphlet GML file from a list of edge rules and edge and graph attributes:
Export an adjacency matrix together with vertex labels and attributes:
Export a Graph object with a raster image as a label: