Table of Contents

Class GraphJson

Namespace
Graph1x.Serialization
Assembly
Graph1x.dll

Imports node-link JSON documents produced by ToJson<TVertex, TEdge>(IReadOnlyGraph<TVertex, TEdge>) or by other tools using the same shape. Vertices are strings; graphs import into multigraph types, the lossless superset. Unknown properties are ignored for forward compatibility; structural problems raise FormatException.

public static class GraphJson
Inheritance
GraphJson
Inherited Members

Methods

Parse(string)

Parses a node-link JSON document, choosing directedness from its directed property.

public static IMutableGraph<string, Edge<string>> Parse(string json)

Parameters

json string

The JSON document text.

Returns

IMutableGraph<string, Edge<string>>

A directed or undirected multigraph over string node ids.

Exceptions

FormatException

The document is not well-formed node-link JSON.

ParseDirected(string)

Parses a node-link JSON document that must declare "directed": true.

public static DirectedMultigraph<string, Edge<string>> ParseDirected(string json)

Parameters

json string

The JSON document text.

Returns

DirectedMultigraph<string, Edge<string>>

The imported directed multigraph.

Exceptions

FormatException

The document is not well-formed node-link JSON or is undirected.

ParseDirectedWeighted(string)

Parses a directed node-link document, reading edge weights from weight properties (0 when absent).

public static DirectedMultigraph<string, WeightedEdge<string, double>> ParseDirectedWeighted(string json)

Parameters

json string

The JSON document text.

Returns

DirectedMultigraph<string, WeightedEdge<string, double>>

The imported weighted directed multigraph.

Exceptions

FormatException

The document is not well-formed node-link JSON, is undirected, or holds a non-numeric weight.

ParseDocument(string)

Parses a node-link JSON document into structure plus attributes: every non-structural scalar property becomes an attribute (string, double, or bool); nulls, arrays, and nested objects are ignored. Directedness follows the directed property.

public static GraphDocument ParseDocument(string json)

Parameters

json string

The JSON document text.

Returns

GraphDocument

The parsed document: graph, vertex data, and edge data.

Exceptions

FormatException

The document is not well-formed node-link JSON.

ParseUndirected(string)

Parses a node-link JSON document that must declare "directed": false.

public static UndirectedMultigraph<string, Edge<string>> ParseUndirected(string json)

Parameters

json string

The JSON document text.

Returns

UndirectedMultigraph<string, Edge<string>>

The imported undirected multigraph.

Exceptions

FormatException

The document is not well-formed node-link JSON or is directed.

ParseUndirectedWeighted(string)

Parses an undirected node-link document, reading edge weights from weight properties (0 when absent).

public static UndirectedMultigraph<string, WeightedEdge<string, double>> ParseUndirectedWeighted(string json)

Parameters

json string

The JSON document text.

Returns

UndirectedMultigraph<string, WeightedEdge<string, double>>

The imported weighted undirected multigraph.

Exceptions

FormatException

The document is not well-formed node-link JSON, is directed, or holds a non-numeric weight.