Utility methods for creating GraphML XML documents for use with the NodeXL Excel Template.
Наследование: Object
Пример #1
0
        DefineCommonGraphMLAttributes
        (
            GraphMLXmlDocument graphMLXmlDocument
        )
        {
            Debug.Assert(graphMLXmlDocument != null);

            NodeXLGraphMLUtil.DefineVertexImageFileGraphMLAttribute(
                graphMLXmlDocument);

            NodeXLGraphMLUtil.DefineVertexCustomMenuGraphMLAttributes(
                graphMLXmlDocument);

            NodeXLGraphMLUtil.DefineEdgeRelationshipGraphMLAttribute(
                graphMLXmlDocument);

            graphMLXmlDocument.DefineEdgeStringGraphMLAttributes(
                EdgeRelationshipDateUtcID, "Relationship Date (UTC)");
        }
Пример #2
0
        DefineEdgeStatusGraphMLAttributes
        (
            GraphMLXmlDocument graphMLXmlDocument
        )
        {
            Debug.Assert(graphMLXmlDocument != null);

            graphMLXmlDocument.DefineEdgeStringGraphMLAttributes(
                EdgeStatusID, "Tweet",
                EdgeStatusUrlsID, "URLs in Tweet",
                EdgeStatusDomainsID, "Domains in Tweet",
                EdgeStatusHashtagsID, "Hashtags in Tweet",
                EdgeStatusDateUtcID, "Tweet Date (UTC)",
                EdgeStatusWebPageUrlID, "Twitter Page for Tweet"
                );

            DefineLatitudeAndLongitudeGraphMLAttributes(graphMLXmlDocument, true);

            NodeXLGraphMLUtil.DefineImportedIDGraphMLAttribute(
                graphMLXmlDocument, true);

            DefineInReplyToStatusIDGraphMLAttribute(graphMLXmlDocument, true);
        }
Пример #3
0
        AppendRepliesToAndMentionsEdgeXmlNode
        (
            GraphMLXmlDocument graphMLXmlDocument,
            String screenName1,
            String screenName2,
            String relationship,
            TwitterStatus twitterStatus
        )
        {
            Debug.Assert(graphMLXmlDocument != null);
            Debug.Assert(!String.IsNullOrEmpty(screenName1));
            Debug.Assert(!String.IsNullOrEmpty(screenName2));
            Debug.Assert(!String.IsNullOrEmpty(relationship));
            Debug.Assert(twitterStatus != null);

            XmlNode edgeXmlNode = NodeXLGraphMLUtil.AppendEdgeXmlNode(
                graphMLXmlDocument, screenName1, screenName2, relationship);

            String  statusDateUtc    = twitterStatus.ParsedDateUtc;
            Boolean hasStatusDateUtc = !String.IsNullOrEmpty(statusDateUtc);

            if (hasStatusDateUtc)
            {
                // The status's date is the relationship date.

                graphMLXmlDocument.AppendGraphMLAttributeValue(edgeXmlNode,
                                                               EdgeRelationshipDateUtcID, statusDateUtc);
            }

            String statusText = twitterStatus.Text;

            graphMLXmlDocument.AppendGraphMLAttributeValue(edgeXmlNode,
                                                           EdgeStatusID, statusText);

            String urls = twitterStatus.Urls;

            if (!String.IsNullOrEmpty(urls))
            {
                graphMLXmlDocument.AppendGraphMLAttributeValue(edgeXmlNode,
                                                               EdgeStatusUrlsID, urls);

                graphMLXmlDocument.AppendGraphMLAttributeValue(edgeXmlNode,
                                                               EdgeStatusDomainsID, UrlsToDomains(urls));
            }

            if (!String.IsNullOrEmpty(twitterStatus.Hashtags))
            {
                graphMLXmlDocument.AppendGraphMLAttributeValue(edgeXmlNode,
                                                               EdgeStatusHashtagsID, twitterStatus.Hashtags);
            }

            if (hasStatusDateUtc)
            {
                graphMLXmlDocument.AppendGraphMLAttributeValue(edgeXmlNode,
                                                               EdgeStatusDateUtcID, statusDateUtc);
            }

            graphMLXmlDocument.AppendGraphMLAttributeValue(edgeXmlNode,
                                                           EdgeStatusWebPageUrlID,

                                                           FormatStatusWebPageUrl(screenName1, twitterStatus)
                                                           );

            AppendLatitudeAndLongitudeGraphMLAttributeValues(
                graphMLXmlDocument, edgeXmlNode, twitterStatus.Latitude,
                twitterStatus.Longitude);

            // Precede the ID with a single quote to force Excel to treat the
            // ID as text.  Otherwise, it formats the ID, which is a large
            // number, in scientific notation.

            graphMLXmlDocument.AppendGraphMLAttributeValue(edgeXmlNode,
                                                           NodeXLGraphMLUtil.ImportedIDID, "'" + twitterStatus.ID);

            AppendInReplyToStatusIDGraphMLAttributeValue(graphMLXmlDocument,
                                                         edgeXmlNode, twitterStatus.InReplyToStatusID);
        }