GetVertexCount ( XmlDocument oGraphMLXmlDocument ) { Debug.Assert(oGraphMLXmlDocument != null); AssertValid(); Int32 iVertexCount = 0; XmlNode oXmlNode; XmlNamespaceManager oXmlNamespaceManager = GraphMLXmlDocument.CreateXmlNamespaceManager( oGraphMLXmlDocument, "g"); if (XmlUtil2.TrySelectSingleNode(oGraphMLXmlDocument, "g:graphml/g:graph/g:node", oXmlNamespaceManager, out oXmlNode)) { while (oXmlNode != null) { if (oXmlNode.Name == "node") { iVertexCount++; } oXmlNode = oXmlNode.NextSibling; } } return(iVertexCount); }
OnNetworkObtained ( XmlDocument oGraphMLXmlDocument, RequestStatistics oRequestStatistics, String sNetworkDescription, String sNetworkTitle, String sPartialFileName ) { Debug.Assert(oGraphMLXmlDocument != null); Debug.Assert(oRequestStatistics != null); Debug.Assert(!String.IsNullOrEmpty(sNetworkDescription)); Debug.Assert(!String.IsNullOrEmpty(sNetworkTitle)); Debug.Assert(!String.IsNullOrEmpty(sPartialFileName)); AssertValid(); XmlNode oGraphXmlNode = XmlUtil2.SelectRequiredSingleNode( oGraphMLXmlDocument, "g:graphml/g:graph", GraphMLXmlDocument.CreateXmlNamespaceManager( oGraphMLXmlDocument, "g") ); XmlUtil2.SetAttributes(oGraphXmlNode, "description", sNetworkDescription); XmlUtil2.SetAttributes(oGraphXmlNode, "suggestedTitle", sNetworkTitle); String sSuggestedFileNameNoExtension = String.Format( "{0} NodeXL {1}" , DateTimeUtil2.ToCultureInvariantFileName( oRequestStatistics.StartTimeUtc), sPartialFileName ); XmlUtil2.SetAttributes(oGraphXmlNode, "suggestedFileNameNoExtension", sSuggestedFileNameNoExtension); if (oRequestStatistics.UnexpectedExceptions > 0) { // The network is partial. throw new PartialNetworkException(oGraphMLXmlDocument, oRequestStatistics); } }