OpenersPrimaryExamplesSection(Spacer1)Examples  (12)

OpenersExampleSection0(Spacer1)Basic Examples  (7)

Import a graph from Graphlet GML, rendered as a (RefLink[Graph, paclet:ref/Graph]) object:

Import["ExampleData/bigdipper.gml",ImagePadding->10]

Import a vertex list and vertex attributes:

Import["ExampleData/bigdipper.gml",{{"VertexList","VertexAttributes"}}]

Show vertex labels and arrowheads in the graph plot:

Import["ExampleData/triangle.gml", VertexLabels-> "Name",ImagePadding->30]

Export a (RefLink[Graph, paclet:ref/Graph]) object to GML:

Export["graph.gml",PetersenGraph[5,2]]

Export a list of edge rules representing a directed graph to GML:

Export["directed.gml",{1->2,1->3,1->5,2->4,2->6,3->4,3->7,4->8,5->6,5->7,6->8,7->8},DirectedEdges->True]

Export an asymmetric adjacency matrix of the same graph represented in the above example to GML:

Export["directed2.gml",{{0,1,1,0,1,0,0,0},{0,0,0,1,0,1,0,0},{0,0,0,1,0,0,1,0},{0,0,0,0,0,0,0,1},{0,0,0,0,0,1,1,0},{0,0,0,0,0,0,0,1},{0,0,0,0,0,0,0,1},{0,0,0,0,0,0,0,0}}, "Graphlet"]

Render an adjacency matrix representation of a Graphlet GML graph as (RefLink[MatrixPlot, paclet:ref/MatrixPlot]):

Import["ExampleData/triangle.gml", "AdjacencyMatrix"]//MatrixPlot

OpenersExampleSection1(Spacer1)Scope  (5)

Construct a list of vertex labels and their attributes in the form of rules:

MapThread[Rule,Import["ExampleData/triangle.gml", {"Graphlet",{"VertexList","VertexAttributes"}}]]

Convert the first graph stored in a Sparse6 file to a Graphlet GML file:

Export["sparse.gml", Import["ExampleData/sparse.s6",{"AdjacencyMatrix", 1}]]

Generate a Graphlet GML file from a list of edge rules and edge and graph attributes:

ExportString[{
"EdgeRules" -> {"A"->"B","B"->"C","C"->"A"},
"GraphAttributes"->{"comment"->"Sample comment"},
"EdgeAttributes"->{
{"label"->"Edge from node A to node B", "weight"->"0.1"},{"label"->"Edge from node B to node C", "weight"->"0.5"},{"label"->"Edge from node C to node A", "weight"->"0.5"}}
}, {"Graphlet", "Rules"}, DirectedEdges->True]

Export an adjacency matrix together with vertex labels and attributes:

ExportString[{
"AdjacencyMatrix" -> {{0,1,1},{1,0,0}, {1,0,0}},
"VertexList"->{"A","B","C"},
"VertexAttributes"->{{"color"->"red"},{},{"color"->"blue"}}
}, {"Graphlet", "Rules"}]

Export a (RefLink[Graph, paclet:ref/Graph]) object with a raster image as a label:

Export["rasterlabel.gml", Graph[{1->2},VertexLabels-> {2-> Graphics[Rasterize[(Sqrt[π])]]}]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {Related Formats:  (RefLink[DOT, paclet:ref/format/DOT])  ▪  (RefLink[Graph6, paclet:ref/format/Graph6])  ▪  (RefLink[GraphML, paclet:ref/format/GraphML])  ▪  (RefLink[GXL, paclet:ref/format/GXL])  ▪  (RefLink[Sparse6, paclet:ref/format/Sparse6])}})}})