LEDA (.gw, .lgr)
Background & Context
-
- LEDA graph data format.
- Commonly used exchange format for graphs.
- Stores a single, typed, directed, or undirected graph.
- Plain text format.
- Native graph file format of the LEDA graph library and the GraphWin application.
- LEDA is an acronym for Library of Efficient Datatypes and Algorithms.
- Developed in the 1990s at Max Planck Institute for Informatics Saarbrücken.
Import & Export
- Import["file.gw"] gives a Graph object representing the graph stored in the specified file.
- Export["file.gw",expr] exports an adjacency matrix or edge information representing a graph to the LEDA format.
- Import["file.gw"] imports the graph from file and returns it as a Graph.
- Import["file.gw",elem] imports the specified element from a LEDA file.
- Import["file.gw",{{elem1,elem2,…}}] imports multiple elements.
- The import format can be specified with Import["file","LEDA"] or Import["file",{"LEDA",elem,…}].
- Export["file.gw",expr,elem] creates a LEDA file by treating expr as specifying element elem.
- Export["file.gw",{expr1,expr2,…},{{elem1,elem2,…}}] treats each expri as specifying the corresponding elemi.
- Export["file.gw",expr,opt1->val1,…] exports expr with the specified option elements taken to have the specified values.
- Export["file.gw",{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 "EdgeData" edge data, given as a list "EdgeRules" connectivity data for the graph, given as a list of rules "EdgeType" edge data type, given as a string "Graph" graph stored in the file, given as a Graph object "Graphics" graph stored in the file, rendered as a graph plot "VertexCount" number of vertices in the graph "VertexData" vertex data, given as a list "VertexType" vertex data type, given as a string - Import by default uses the "Graph" element when importing from LEDA.
Options
- General Import options:
-
ImageSize Automatic specifies the overall size of the image to display for a graph - When importing from LEDA, 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.
Examples
Basic Examples (8)
Import a Graph object from a LEDA file:
Show vertex labels in the Graph:
Show the Import elements available for a LEDA file:
Import the edge and vertex data stored in a LEDA graph file:
Export a Graph to the LEDA format:
Export an asymmetric adjacency matrix of a graph to the LEDA format:
Convert a list of edge rules representing an undirected graph to the LEDA language: