Class GraphMl
- Namespace
- Graph1x.Serialization
- Assembly
- Graph1x.dll
Imports GraphML documents produced by ToGraphMl<TVertex, TEdge>(IReadOnlyGraph<TVertex, TEdge>) or by other tools. Vertices are strings (GraphML node ids); graphs import into multigraph types, the lossless superset, since GraphML permits parallel edges. Unknown elements and attributes are ignored for forward compatibility; structural problems raise FormatException.
public static class GraphMl
- Inheritance
-
GraphMl
- Inherited Members
Methods
Parse(string)
Parses a GraphML document, choosing directedness from its edgedefault.
public static IMutableGraph<string, Edge<string>> Parse(string xml)
Parameters
xmlstringThe GraphML document text.
Returns
- IMutableGraph<string, Edge<string>>
A directed or undirected multigraph over string vertex ids.
Exceptions
- FormatException
The document is not well-formed GraphML.
ParseDirected(string)
Parses a GraphML document that must declare edgedefault="directed".
public static DirectedMultigraph<string, Edge<string>> ParseDirected(string xml)
Parameters
xmlstringThe GraphML document text.
Returns
- DirectedMultigraph<string, Edge<string>>
The imported directed multigraph.
Exceptions
- FormatException
The document is not well-formed GraphML or is undirected.
ParseDirectedWeighted(string, string)
Parses a directed GraphML document, reading edge weights from weightKey data elements (0 when absent).
public static DirectedMultigraph<string, WeightedEdge<string, double>> ParseDirectedWeighted(string xml, string weightKey = "weight")
Parameters
Returns
- DirectedMultigraph<string, WeightedEdge<string, double>>
The imported weighted directed multigraph.
Exceptions
- FormatException
The document is not well-formed GraphML, is undirected, or holds a non-numeric weight.
ParseDocument(string)
Parses a GraphML document into structure plus attributes: data
elements are resolved through the document's <key>
declarations (id → attr.name) and typed per their attr.type;
undeclared keys import as strings. Directedness follows
edgedefault.
public static GraphDocument ParseDocument(string xml)
Parameters
xmlstringThe GraphML document text.
Returns
- GraphDocument
The parsed document: graph, vertex data, and edge data.
Exceptions
- FormatException
The document is not well-formed GraphML or a value does not match its declared type.
ParseUndirected(string)
Parses a GraphML document that must declare edgedefault="undirected".
public static UndirectedMultigraph<string, Edge<string>> ParseUndirected(string xml)
Parameters
xmlstringThe GraphML document text.
Returns
- UndirectedMultigraph<string, Edge<string>>
The imported undirected multigraph.
Exceptions
- FormatException
The document is not well-formed GraphML or is directed.
ParseUndirectedWeighted(string, string)
Parses an undirected GraphML document, reading edge weights from weightKey data elements (0 when absent).
public static UndirectedMultigraph<string, WeightedEdge<string, double>> ParseUndirectedWeighted(string xml, string weightKey = "weight")
Parameters
Returns
- UndirectedMultigraph<string, WeightedEdge<string, double>>
The imported weighted undirected multigraph.
Exceptions
- FormatException
The document is not well-formed GraphML, is directed, or holds a non-numeric weight.