コード例 #1
0
        GetNetworkInternal
        (
            String sSearchTerm,
            WhatToInclude eWhatToInclude,
            Int32 iMaximumStatuses,
            RequestStatistics oRequestStatistics,
            GraphMLXmlDocument oGraphMLXmlDocument
        )
        {
            Debug.Assert(!String.IsNullOrEmpty(sSearchTerm));
            Debug.Assert(iMaximumStatuses > 0);
            Debug.Assert(iMaximumStatuses != Int32.MaxValue);
            Debug.Assert(oRequestStatistics != null);
            Debug.Assert(oGraphMLXmlDocument != null);
            AssertValid();

            // The key is the Twitter user ID and the value is the corresponding
            // TwitterUser.

            Dictionary <String, TwitterUser> oUserIDDictionary =
                new Dictionary <String, TwitterUser>();

            // First, append a vertex for each person who has tweeted the search
            // term.

            AppendVertexXmlNodesForSearchTerm(sSearchTerm, eWhatToInclude,
                                              iMaximumStatuses, oGraphMLXmlDocument, oUserIDDictionary,
                                              oRequestStatistics);

            // Now append a vertex for each person who was mentioned or replied to
            // by the first set of people, but who didn't tweet the search term
            // himself.

            AppendVertexXmlNodesForMentionsAndRepliesTo(eWhatToInclude,
                                                        oGraphMLXmlDocument, oUserIDDictionary, oRequestStatistics);

            TwitterSearchNetworkGraphMLUtil.AppendVertexTooltipXmlNodes(
                oGraphMLXmlDocument, oUserIDDictionary);

            if (WhatToIncludeFlagIsSet(eWhatToInclude,
                                       WhatToInclude.FollowedEdges))
            {
                // Look at each author's friends, and if a friend has also tweeted
                // the search term, add an edge between the author and the friend.

                AppendFriendEdgeXmlNodes(oUserIDDictionary, MaximumFriends,
                                         oGraphMLXmlDocument, oRequestStatistics);
            }

            AppendRepliesToAndMentionsEdgeXmlNodes(oGraphMLXmlDocument,
                                                   oUserIDDictionary.Values,

                                                   TwitterGraphMLUtil.TwitterUsersToUniqueScreenNames(
                                                       oUserIDDictionary.Values)
                                                   );
        }
コード例 #2
0
        AppendFriendEdgeXmlNodes
        (
            Dictionary <String, TwitterUser> oUserIDDictionary,
            Int32 iMaximumPeoplePerRequest,
            GraphMLXmlDocument oGraphMLXmlDocument,
            RequestStatistics oRequestStatistics
        )
        {
            Debug.Assert(oUserIDDictionary != null);
            Debug.Assert(iMaximumPeoplePerRequest > 0);
            Debug.Assert(oGraphMLXmlDocument != null);
            Debug.Assert(oRequestStatistics != null);
            AssertValid();

            AppendFriendEdgeXmlNodes(

                TwitterGraphMLUtil.TwitterUsersToUniqueScreenNames(
                    oUserIDDictionary.Values),

                oUserIDDictionary, iMaximumPeoplePerRequest, oGraphMLXmlDocument,
                oRequestStatistics);
        }