GDF Format

GDF is the file formate used by The Graph Exploration System (GUESS) . It is build similar to a database table or CSV. Both edge and node data is defined in a single file, each initiated by their respective headers. Each element (i.e. node or edge) is on a line and values are separated by comma. Node definition is started by "nodedef>name" and edge definition by "edgedef>node1". For nodes, only the name is needed to build, but for edges both “node1” and “node2” are required, which are the names of the two nodes you are connecting.

Example

This example demonstrates a possible gdf data structure.


nodedef>name VARCHAR,label VARCHAR
s1,Site number 1
s2,Site number 2
s3,Site number 3
edgedef>node1 VARCHAR,node2 VARCHAR, weight DOUBLE
s1,s2,1.2341
s2,s3,0.453
s3,s2, 2.34
s3,s1, 0.871


Reading GDF files

To read GDF files, just use the ofFile function located in the gdf module of the FSharp.FGL.IO namespace. It does not need anything but the file path ans will return the vertices and edges as a vertex list, edge list tupel.

open FSharp.FGL.IO.GDF

let fileDir = __SOURCE_DIRECTORY__ + "/data/"

let path = fileDir + "GDFExample.txt"

let gdfFileRead = GDF.fromFile path

Additionally, you can use the fromArray function instead of fromFile to directly transform an array to a vertex list, edge list tupel.
open FSharp.FGL.IO.GDF

let gdfArrayRead = GDF.fromArray [|"nodedef>name VARCHAR,label VARCHAR";"s1,Site number 1";"s2,Site number 2";"edgedef>node1 VARCHAR,node2 VARCHAR,weight DOUBLE";"s1,s2,1.2341"|]

Writing GDF format files

To save a graph that takes the same form as a graph created by the reading GDF file functions, the toFile function can be applied. This function needs the vertex list and the edge list of the graph and saves the gdf file at the given path.

open FSharp.FGL.IO.GDF

let pathSave    = fileDir + "GDFExampleToFile.txt"

let vertexList  = (fst gdfFileRead)

let edgeList    = (snd gdfFileRead)

GDF.toFile vertexList edgeList pathSave
Multiple items
Namespace FSharp

--------------------
Namespace Microsoft.FSharp
Namespace FSharp.FGL
Namespace FSharp.FGL.IO
Namespace FSharp.FGL.IO.GDF
val fileDir : string
val path : string
val gdfFileRead : FSharp.FGL.LVertex<GDF.GDFValue,Map<string,GDF.GDFValue>> list * FSharp.FGL.LEdge<GDF.GDFValue,Map<string,GDF.GDFValue>> list
Modul GDF

aus FSharp.FGL.IO.GDF
val fromFile : path:string -> FSharp.FGL.LVertex<GDF.GDFValue,Map<string,GDF.GDFValue>> list * FSharp.FGL.LEdge<GDF.GDFValue,Map<string,GDF.GDFValue>> list
val gdfArrayRead : FSharp.FGL.LVertex<GDF.GDFValue,Map<string,GDF.GDFValue>> list * FSharp.FGL.LEdge<GDF.GDFValue,Map<string,GDF.GDFValue>> list
val fromArray : data:string [] -> FSharp.FGL.LVertex<GDF.GDFValue,Map<string,GDF.GDFValue>> list * FSharp.FGL.LEdge<GDF.GDFValue,Map<string,GDF.GDFValue>> list
val pathSave : string
val vertexList : FSharp.FGL.LVertex<GDF.GDFValue,Map<string,GDF.GDFValue>> list
val fst : tuple:('T1 * 'T2) -> 'T1
val edgeList : FSharp.FGL.LEdge<GDF.GDFValue,Map<string,GDF.GDFValue>> list
val snd : tuple:('T1 * 'T2) -> 'T2
val toFile : vertexList:FSharp.FGL.LVertex<GDF.GDFValue,Map<string,GDF.GDFValue>> list -> edgeList:FSharp.FGL.LEdge<GDF.GDFValue,Map<string,GDF.GDFValue>> list -> path:string -> unit