/// <summary>
        /// Deserializes from XML <paramref name="reader"/> (GraphML graph) into the given <paramref name="graph"/>.
        /// </summary>
        /// <typeparam name="TVertex">Vertex type.</typeparam>
        /// <typeparam name="TEdge">Edge type.</typeparam>
        /// <typeparam name="TGraph">Graph type.</typeparam>
        /// <param name="graph">Graph instance to fill.</param>
        /// <param name="reader">The XML reader.</param>
        /// <param name="vertexFactory">Vertex factory method.</param>
        /// <param name="edgeFactory">Edge factory method.</param>
        /// <exception cref="T:System.ArgumentNullException"><paramref name="graph"/> is <see langword="null"/>.</exception>
        /// <exception cref="T:System.ArgumentNullException"><paramref name="reader"/> is <see langword="null"/>.</exception>
        /// <exception cref="T:System.ArgumentNullException"><paramref name="vertexFactory"/> is <see langword="null"/>.</exception>
        /// <exception cref="T:System.ArgumentNullException"><paramref name="edgeFactory"/> is <see langword="null"/>.</exception>
        /// <exception cref="T:System.InvalidOperationException">Deserializing value on property without setter, or with invalid default value.</exception>
        /// <exception cref="T:System.InvalidOperationException"><see cref="XmlConstants.GraphMLTag"/> or <see cref="XmlConstants.GraphTag"/> not found.</exception>
        /// <exception cref="T:System.InvalidOperationException">Failure while reading elements from GraphML.</exception>
        /// <exception cref="T:System.NotSupportedException">Deserializing graph with unsupported property type.</exception>
        public static void DeserializeFromGraphML <TVertex, TEdge, TGraph>(
            [NotNull] this TGraph graph,
            [NotNull] XmlReader reader,
            [NotNull] IdentifiableVertexFactory <TVertex> vertexFactory,
            [NotNull] IdentifiableEdgeFactory <TVertex, TEdge> edgeFactory)
            where TEdge : IEdge <TVertex>
            where TGraph : IMutableVertexAndEdgeSet <TVertex, TEdge>
        {
            var serializer = new GraphMLDeserializer <TVertex, TEdge, TGraph>();

            serializer.Deserialize(reader, graph, vertexFactory, edgeFactory);
        }
        /// <summary>
        /// Deserializes from the given <paramref name="reader"/> (GraphML graph) into the given <paramref name="graph"/>
        /// and checks if content is valid.
        /// </summary>
        /// <typeparam name="TVertex">Vertex type.</typeparam>
        /// <typeparam name="TEdge">Edge type.</typeparam>
        /// <typeparam name="TGraph">Graph type.</typeparam>
        /// <param name="graph">Graph instance to fill.</param>
        /// <param name="reader">Reader stream.</param>
        /// <param name="vertexFactory">Vertex factory method.</param>
        /// <param name="edgeFactory">Edge factory method.</param>
        /// <exception cref="T:System.ArgumentNullException"><paramref name="graph"/> is <see langword="null"/>.</exception>
        /// <exception cref="T:System.ArgumentNullException"><paramref name="reader"/> is <see langword="null"/>.</exception>
        /// <exception cref="T:System.ArgumentNullException"><paramref name="vertexFactory"/> is <see langword="null"/>.</exception>
        /// <exception cref="T:System.ArgumentNullException"><paramref name="edgeFactory"/> is <see langword="null"/>.</exception>
        /// <exception cref="T:System.InvalidOperationException">Deserializing value on property without setter, or with invalid default value.</exception>
        /// <exception cref="T:System.InvalidOperationException"><see cref="XmlConstants.GraphMLTag"/> or <see cref="XmlConstants.GraphTag"/> not found.</exception>
        /// <exception cref="T:System.InvalidOperationException">Failure while reading elements from GraphML.</exception>
        /// <exception cref="T:System.NotSupportedException">Deserializing graph with unsupported property type.</exception>
        public static void DeserializeAndValidateFromGraphML <TVertex, TEdge, TGraph>(
            [NotNull] this TGraph graph,
            [NotNull] TextReader reader,
            [NotNull] IdentifiableVertexFactory <TVertex> vertexFactory,
            [NotNull] IdentifiableEdgeFactory <TVertex, TEdge> edgeFactory)
            where TEdge : IEdge <TVertex>
            where TGraph : IMutableVertexAndEdgeSet <TVertex, TEdge>
        {
            if (reader is null)
            {
                throw new ArgumentNullException(nameof(reader));
            }

            var serializer = new GraphMLDeserializer <TVertex, TEdge, TGraph>();

            var resolver = new GraphMLXmlResolver();
            var settings = new XmlReaderSettings
            {
                ValidationType = ValidationType.Schema,
                XmlResolver    = resolver,
                DtdProcessing  = DtdProcessing.Ignore
            };

            settings.ValidationFlags |= XmlSchemaValidationFlags.ProcessInlineSchema;
            settings.ValidationFlags |= XmlSchemaValidationFlags.ProcessSchemaLocation;
            settings.ValidationFlags |= XmlSchemaValidationFlags.ReportValidationWarnings;

            // Add GraphML schema
            AddGraphMLSchema(settings, resolver);

            try
            {
                settings.ValidationEventHandler += ValidationEventHandler;

                // Read and validate
                using (var xmlReader = XmlReader.Create(reader, settings))
                {
                    serializer.Deserialize(xmlReader, graph, vertexFactory, edgeFactory);
                }
            }
            finally
            {
                settings.ValidationEventHandler -= ValidationEventHandler;
            }
        }