Table of Contents

Class GraphJsonExtensions

Namespace
Graph1x.Serialization
Assembly
Graph1x.dll

Exports graphs to JSON in the node-link shape used across the ecosystem (NetworkX, D3): { "directed": ..., "nodes": [...], "edges": [...] }. Written with Utf8JsonWriter directly — no reflection-based serialization — with deterministic property order and invariant number formatting.

public static class GraphJsonExtensions
Inheritance
GraphJsonExtensions
Inherited Members

Methods

ToJson<TVertex, TEdge>(IReadOnlyGraph<TVertex, TEdge>)

Renders the graph as node-link JSON with default options.

public static string ToJson<TVertex, TEdge>(this IReadOnlyGraph<TVertex, TEdge> graph) where TVertex : notnull where TEdge : IEdge<TVertex>

Parameters

graph IReadOnlyGraph<TVertex, TEdge>

The graph to render.

Returns

string

The JSON document text.

Type Parameters

TVertex

The vertex type.

TEdge

The edge type.

ToJson<TVertex, TEdge>(IReadOnlyGraph<TVertex, TEdge>, GraphJsonExportOptions<TVertex, TEdge>)

Renders the graph as node-link JSON.

public static string ToJson<TVertex, TEdge>(this IReadOnlyGraph<TVertex, TEdge> graph, GraphJsonExportOptions<TVertex, TEdge> options) where TVertex : notnull where TEdge : IEdge<TVertex>

Parameters

graph IReadOnlyGraph<TVertex, TEdge>

The graph to render.

options GraphJsonExportOptions<TVertex, TEdge>

Rendering options.

Returns

string

The JSON document text.

Type Parameters

TVertex

The vertex type.

TEdge

The edge type.

Exceptions

ArgumentNullException

Either argument is null.