Class SerializationExtensions
Extensions to serialize/deserialize graphs.
Inheritance
Inherited Members
Namespace: QuikGraph.Serialization
Assembly: QuikGraph.Serialization.dll
Syntax
public static class SerializationExtensions
Methods
| Improve this Doc View SourceDeserializeFromBinary<TVertex, TEdge, TGraph>(Stream, SerializationBinder)
Deserializes a graph instance from a stream
that was serialized using the .NET serialization binary formatter.
Declaration
public static TGraph DeserializeFromBinary<TVertex, TEdge, TGraph>(this Stream stream, SerializationBinder binder = null)
where TEdge : IEdge<TVertex> where TGraph : IGraph<TVertex, TEdge>
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | Stream from which deserializing the graph. |
System.Runtime.Serialization.SerializationBinder | binder | System.Runtime.Serialization.SerializationBinder used during deserialization. It can be used to check/filter/replace/upgrade types that are loaded. It is also useful in security scenarios. By default no binder is used. |
Returns
Type | Description |
---|---|
TGraph | Deserialized graph. |
Type Parameters
Name | Description |
---|---|
TVertex | Vertex type. |
TEdge | Edge type. |
TGraph | Graph type. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentException |
|
DeserializeFromXml<TVertex, TEdge, TGraph>(XmlReader, Predicate<XmlReader>, Predicate<XmlReader>, Predicate<XmlReader>, Func<XmlReader, TGraph>, Func<XmlReader, TVertex>, Func<XmlReader, TEdge>)
Deserializes a graph instance from a generic XML stream, using an System.Xml.XmlReader.
Declaration
public static TGraph DeserializeFromXml<TVertex, TEdge, TGraph>(this XmlReader reader, Predicate<XmlReader> graphPredicate, Predicate<XmlReader> vertexPredicate, Predicate<XmlReader> edgePredicate, Func<XmlReader, TGraph> graphFactory, Func<XmlReader, TVertex> vertexFactory, Func<XmlReader, TEdge> edgeFactory)
where TEdge : IEdge<TVertex> where TGraph : class, IMutableVertexAndEdgeSet<TVertex, TEdge>
Parameters
Type | Name | Description |
---|---|---|
System.Xml.XmlReader | reader | Input XML reader. |
System.Predicate<System.Xml.XmlReader> | graphPredicate | Predicate that returns a value indicating if the current XML node is a graph. The first match is considered. |
System.Predicate<System.Xml.XmlReader> | vertexPredicate | Predicate that returns a value indicating if the current XML node is a vertex. |
System.Predicate<System.Xml.XmlReader> | edgePredicate | Predicate that returns a value indicating if the current XML node is an edge. |
System.Func<System.Xml.XmlReader, TGraph> | graphFactory | Delegate that instantiates the empty graph instance, given the graph node. |
System.Func<System.Xml.XmlReader, TVertex> | vertexFactory | Delegate that instantiates a vertex instance, given the vertex node. |
System.Func<System.Xml.XmlReader, TEdge> | edgeFactory | Delegate that instantiates an edge instance, given the edge node. |
Returns
Type | Description |
---|---|
TGraph | Deserialized graph. |
Type Parameters
Name | Description |
---|---|
TVertex | Vertex type. |
TEdge | Edge type. |
TGraph | Graph type. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentNullException |
|
System.ArgumentNullException |
|
System.ArgumentNullException |
|
System.ArgumentNullException |
|
System.ArgumentNullException |
|
System.ArgumentNullException |
|
System.InvalidOperationException | If the graph node cannot be found. |
DeserializeFromXml<TVertex, TEdge, TGraph>(XmlReader, String, String, String, String, Func<XmlReader, TGraph>, Func<XmlReader, TVertex>, Func<XmlReader, TEdge>)
Deserializes a graph from a generic XML stream, using an System.Xml.XmlReader.
Declaration
public static TGraph DeserializeFromXml<TVertex, TEdge, TGraph>(this XmlReader reader, string graphElementName, string vertexElementName, string edgeElementName, string namespaceUri, Func<XmlReader, TGraph> graphFactory, Func<XmlReader, TVertex> vertexFactory, Func<XmlReader, TEdge> edgeFactory)
where TEdge : IEdge<TVertex> where TGraph : class, IMutableVertexAndEdgeSet<TVertex, TEdge>
Parameters
Type | Name | Description |
---|---|---|
System.Xml.XmlReader | reader | Input XML reader. |
System.String | graphElementName | Name of the XML node holding graph information. The first node is considered. |
System.String | vertexElementName | Name of the XML node holding vertex information. |
System.String | edgeElementName | Name of the XML node holding edge information. |
System.String | namespaceUri | XML namespace. |
System.Func<System.Xml.XmlReader, TGraph> | graphFactory | Delegate that instantiates the empty graph instance, given the graph node. |
System.Func<System.Xml.XmlReader, TVertex> | vertexFactory | Delegate that instantiates a vertex instance, given the vertex node. |
System.Func<System.Xml.XmlReader, TEdge> | edgeFactory | Delegate that instantiates an edge instance, given the edge node. |
Returns
Type | Description |
---|---|
TGraph | Deserialized graph. |
Type Parameters
Name | Description |
---|---|
TVertex | Vertex type. |
TEdge | Edge type. |
TGraph | Graph type. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentNullException |
|
System.ArgumentNullException |
|
System.ArgumentNullException |
|
System.ArgumentNullException |
|
System.ArgumentException |
|
System.ArgumentException |
|
System.ArgumentException |
|
System.InvalidOperationException | If the graph node cannot be found. |
DeserializeFromXml<TVertex, TEdge, TGraph>(IXPathNavigable, String, String, String, Func<XPathNavigator, TGraph>, Func<XPathNavigator, TVertex>, Func<XPathNavigator, TEdge>)
Deserializes a graph instance from a generic XML stream, using an System.Xml.XPath.XPathDocument.
Declaration
public static TGraph DeserializeFromXml<TVertex, TEdge, TGraph>(this IXPathNavigable document, string graphXPath, string vertexXPath, string edgeXPath, Func<XPathNavigator, TGraph> graphFactory, Func<XPathNavigator, TVertex> vertexFactory, Func<XPathNavigator, TEdge> edgeFactory)
where TEdge : IEdge<TVertex> where TGraph : IMutableVertexAndEdgeSet<TVertex, TEdge>
Parameters
Type | Name | Description |
---|---|---|
System.Xml.XPath.IXPathNavigable | document | Input XML document. |
System.String | graphXPath | XPath expression to the graph node. The first node is considered. |
System.String | vertexXPath | XPath expression from the graph node to the vertex nodes. |
System.String | edgeXPath | XPath expression from the graph node to the edge nodes. |
System.Func<System.Xml.XPath.XPathNavigator, TGraph> | graphFactory | Delegate that instantiates the empty graph instance, given the graph node. |
System.Func<System.Xml.XPath.XPathNavigator, TVertex> | vertexFactory | Delegate that instantiates a vertex instance, given the vertex node. |
System.Func<System.Xml.XPath.XPathNavigator, TEdge> | edgeFactory | Delegate that instantiates an edge instance, given the edge node. |
Returns
Type | Description |
---|---|
TGraph | Deserialized graph. |
Type Parameters
Name | Description |
---|---|
TVertex | Vertex type. |
TEdge | Edge type. |
TGraph | Graph type. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentNullException |
|
System.ArgumentNullException |
|
System.ArgumentNullException |
|
System.ArgumentException |
|
System.ArgumentException |
|
System.ArgumentException |
|
System.InvalidOperationException | If the |
SerializeToBinary<TVertex, TEdge>(IGraph<TVertex, TEdge>, Stream)
Serializes the graph
to the stream
using the .NET serialization binary formatter.
Declaration
public static void SerializeToBinary<TVertex, TEdge>(this IGraph<TVertex, TEdge> graph, Stream stream)
where TEdge : IEdge<TVertex>
Parameters
Type | Name | Description |
---|---|---|
IGraph<TVertex, TEdge> | graph | The graph to serialize. |
System.IO.Stream | stream | Stream in which serializing the graph. |
Type Parameters
Name | Description |
---|---|
TVertex | Vertex type. |
TEdge | Edge type. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentNullException |
|
System.ArgumentException |
|
SerializeToXml<TVertex, TEdge, TGraph>(TGraph, XmlWriter, VertexIdentity<TVertex>, EdgeIdentity<TVertex, TEdge>, String, String, String, String)
Serializes a graph instance to a generic XML stream, using an System.Xml.XmlWriter.
Declaration
public static void SerializeToXml<TVertex, TEdge, TGraph>(this TGraph graph, XmlWriter writer, VertexIdentity<TVertex> vertexIdentity, EdgeIdentity<TVertex, TEdge> edgeIdentity, string graphElementName, string vertexElementName, string edgeElementName, string namespaceUri)
where TEdge : IEdge<TVertex> where TGraph : IEdgeListGraph<TVertex, TEdge>
Parameters
Type | Name | Description |
---|---|---|
TGraph | graph | Graph to serialize. |
System.Xml.XmlWriter | writer | XML writer. |
VertexIdentity<TVertex> | vertexIdentity | The vertex identity. |
EdgeIdentity<TVertex, TEdge> | edgeIdentity | The edge identity. |
System.String | graphElementName | Name of the graph element. |
System.String | vertexElementName | Name of the vertex element. |
System.String | edgeElementName | Name of the edge element. |
System.String | namespaceUri | XML namespace. |
Type Parameters
Name | Description |
---|---|
TVertex | Vertex type. |
TEdge | Edge type. |
TGraph | Graph type. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentNullException |
|
System.ArgumentNullException |
|
System.ArgumentNullException |
|
System.ArgumentNullException |
|
System.ArgumentException |
|
System.ArgumentException |
|
System.ArgumentException |
|
SerializeToXml<TVertex, TEdge, TGraph>(TGraph, XmlWriter, VertexIdentity<TVertex>, EdgeIdentity<TVertex, TEdge>, String, String, String, String, Action<XmlWriter, TGraph>, Action<XmlWriter, TVertex>, Action<XmlWriter, TEdge>)
Serializes a graph instance to a generic XML stream, using an System.Xml.XmlWriter.
Declaration
public static void SerializeToXml<TVertex, TEdge, TGraph>(this TGraph graph, XmlWriter writer, VertexIdentity<TVertex> vertexIdentity, EdgeIdentity<TVertex, TEdge> edgeIdentity, string graphElementName, string vertexElementName, string edgeElementName, string namespaceUri, Action<XmlWriter, TGraph> writeGraphAttributes, Action<XmlWriter, TVertex> writeVertexAttributes, Action<XmlWriter, TEdge> writeEdgeAttributes)
where TEdge : IEdge<TVertex> where TGraph : IEdgeListGraph<TVertex, TEdge>
Parameters
Type | Name | Description |
---|---|---|
TGraph | graph | Graph to serialize. |
System.Xml.XmlWriter | writer | XML writer. |
VertexIdentity<TVertex> | vertexIdentity | The vertex identity. |
EdgeIdentity<TVertex, TEdge> | edgeIdentity | The edge identity. |
System.String | graphElementName | Name of the graph element. |
System.String | vertexElementName | Name of the vertex element. |
System.String | edgeElementName | Name of the edge element. |
System.String | namespaceUri | XMl namespace. |
System.Action<System.Xml.XmlWriter, TGraph> | writeGraphAttributes | Delegate to write graph attributes (optional). |
System.Action<System.Xml.XmlWriter, TVertex> | writeVertexAttributes | Delegate to write vertex attributes (optional). |
System.Action<System.Xml.XmlWriter, TEdge> | writeEdgeAttributes | Delegate to write edge attributes (optional). |
Type Parameters
Name | Description |
---|---|
TVertex | Vertex type. |
TEdge | Edge type. |
TGraph | Graph type. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentNullException |
|
System.ArgumentNullException |
|
System.ArgumentNullException |
|
System.ArgumentNullException |
|
System.ArgumentException |
|
System.ArgumentException |
|
System.ArgumentException |
|