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
1: 2: 3: 4: 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 ```fsharp let graph = Model.empty Directed ``` </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 ```fsharp graph |> addNode 1 "Node A" |> addNode 2 "Node B" ``` </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. > **Note:** If `src` or `dst` have not been added via `addNode`, > the edge will still be created in the edge dictionaries, but the > nodes will be missing from `graph.Nodes`. This creates "ghost nodes" > that are traversable but invisible to functions that iterate over > nodes (e.g. `order`, `allNodes`). Use `addEdgeEnsured` to > auto-create missing endpoints with a default value. ## Example ```fsharp graph |> addEdge 1 2 10 ``` </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 ```fsharp 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 ```fsharp 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
|