Gdf Module
GDF (GUESS Graph Format) serialization support.
Provides functions to serialize graphs in GDF format, a simple text-based format used by Gephi and other graph visualization tools. GDF uses a column-based format similar to CSV with separate sections for nodes and edges.
Format Overview
GDF files consist of two sections: - nodedef> - Defines node columns and data - edgedef> - Defines edge columns and data
Example
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: |
|
Output Format
nodedef>name VARCHAR,label VARCHAR 1,Alice 2,Bob edgedef>node1 VARCHAR,node2 VARCHAR,weight VARCHAR 1,2,5
<summary> Core graph data structures and basic operations for the yog library. This module defines the fundamental `Graph` type and provides all basic operations for creating and manipulating graphs. The graph uses an adjacency list representation with dual indexing (both outgoing and incoming edges) for efficient traversal in both directions. </summary>
<summary> Creates a new empty graph of the specified type. ## Example let graph = Model.empty Directed ## Parameters - `graphType`: The type of the graph. ## Returns A new empty graph. </summary>
<summary> A directed graph where edges have a direction from source to destination. </summary>
<summary> Adds a node to the graph with the given ID and data. If a node with this ID already exists, its data will be replaced. ## Example graph |> addNode 1 "Node A" |> addNode 2 "Node B" ## Parameters - `id`: The unique identifier for the node. - `data`: The data to store at the node. - `graph`: The graph to add the node to. ## Returns A new graph with the node added. </summary>
<summary> Adds an edge to the graph with the given weight. For directed graphs, adds a single edge from src to dst. For undirected graphs, adds edges in both directions. ## Example graph |> addEdge 1 2 10 **Note:** If `src` or `dst` have not been added via `addNode`, an `ArgumentException` is thrown. To automatically create missing endpoints when adding an edge, use `addEdgeEnsured` or `addEdgeEnsuredWith`. ## Parameters - `src`: The source node ID. - `dst`: The destination node ID. - `weight`: The weight of the edge. - `graph`: The graph to add the edge to. ## Returns A new graph with the edge added. </summary>
<summary> GDF (GUESS Graph Format) serialization support. Provides functions to serialize graphs in GDF format, a simple text-based format used by Gephi and other graph visualization tools. GDF uses a column-based format similar to CSV with separate sections for nodes and edges. ## Format Overview GDF files consist of two sections: - **nodedef>** - Defines node columns and data - **edgedef>** - Defines edge columns and data ## Example open Yog.IO open Yog.Model // Create a simple graph let graph = empty Directed |> addNode 1 "Alice" |> addNode 2 "Bob" |> addEdge 1 2 5 // Serialize to GDF let gdf = Gdf.serialize graph File.WriteAllText("graph.gdf", gdf) ## Output Format nodedef>name VARCHAR,label VARCHAR 1,Alice 2,Bob edgedef>node1 VARCHAR,node2 VARCHAR,weight VARCHAR 1,2,5 </summary>
<summary> Serializes a graph to GDF format where node and edge data are strings. This is a simplified version of `serializeWith` for graphs where node data and edge data are already strings. The string data is used as the "label" attribute for both nodes and edges. **Time Complexity:** O(V + E) ## Example let graph = empty Directed |> addNode 1 "Alice" |> addNode 2 "Bob" |> addEdge 1 2 "friend" let gdf = Gdf.serialize graph File.WriteAllText("graph.gdf", gdf) </summary>
Types
| Type | Description |
|
Options for GDF serialization. |
Functions and values
| Function or value |
Description
|
||
|
Default GDF serialization options.
|
||
|
Serializes a graph to GDF format where node and edge data are strings. This is a simplified version of Time Complexity: O(V + E)
Example
val graph: obj
val gdf: obj
|
||
|
Serializes a graph to GDF format with integer edge weights. This is a convenience function for the common case of graphs with integer weights. Node data is used as labels, and edge weights are serialized to the "weight" column. Time Complexity: O(V + E)
Example
val graph: obj
val gdf: obj
|
||
|
Serializes a graph to GDF format with custom attribute mappers and options. This function allows you to control how node and edge data are converted to GDF attributes, and customize the output format. Time Complexity: O(V + E)
Example
Use Cases
type Person =
{
Name: string
Age: int
}
Multiple items
val string: value: 'T -> string -------------------- type string = System.String Multiple items
val int: value: 'T -> int (requires member op_Explicit) -------------------- type int = int32 -------------------- type int<'Measure> = int type Connection =
{
Weight: int
Type: string
}
val graph: obj
val nodeAttrs: p: Person -> (string * string) list
val p: Person
Person.Name: string
Person.Age: int
val edgeAttrs: c: Connection -> (string * string) list
val c: Connection
Connection.Weight: int
Connection.Type: string
val gdf: obj
|
||
|
Serializes a graph to GDF format with custom options. Uses default attribute mapping (single "label" column) but allows customization of separator and type annotations. Time Complexity: O(V + E)
Example
val options: 'a
val gdf: obj
|