Ejemplo n.º 1
0
        // Add 'mention edge' between each pair of users in ego-network
        public void addMentionCount()
        {
            foreach (long memberID1 in memberIDtoIndex.Keys)
            {
                // Node index of member 1
                int memberIndex1 = userIDtoIndex[memberID1];

                // For checking 'Friendshp' potential links
                if (!allLinksFromNodes.ContainsKey(memberIndex1))
                {
                    continue;
                }

                // Get mention count
                var    mentionCounts      = new Dictionary <int, int>();
                double sumLogMentionCount = 0;
                foreach (long memberID2 in memberIDtoIndex.Keys)
                {
                    if (memberID1 == memberID2)
                    {
                        continue;
                    }

                    int mentionCount = dbAdapter.getMentionCount(memberID1, memberID2);
                    if (mentionCount > 1)
                    {
                        mentionCounts.Add(userIDtoIndex[memberID2], mentionCount);
                        sumLogMentionCount += Math.Log(mentionCount);
                    }
                }

                // Get the number of friendship links
                int nFriendhips = 0;
                foreach (ForwardLink friendship in allLinksFromNodes[memberIndex1])
                {
                    if (friendship.type == EdgeType.FRIENDSHIP)
                    {
                        nFriendhips += 1;
                    }
                }
                // Normalize weight of 'Mention type edge'
                // Add link with the weight as much as mention frequency
                if (sumLogMentionCount > 1)
                {
                    foreach (int memberIndex2 in mentionCounts.Keys)
                    {
                        double weight = nFriendhips * Math.Log(mentionCounts[memberIndex2]) / sumLogMentionCount; // Mention Edge Weight
                        addLink(memberIndex1, memberIndex2, EdgeType.MENTION, weight);
                    }
                }
            }
        }