/// <summary>
        ///     Get the shortest path of users between two users
        /// </summary>
        /// <param name="user1">First user</param>
        /// <param name="user2">Second user</param>
        /// <returns>Enumeration of users from shortest path between two users</returns>
        public IEnumerable <User> GetShortestPath(Guid user1, Guid user2)
        {
            work = new UnitOfWork();
            var shortestPathId = AnalyzerBridge.GetShortestPath(
                work.Connections.GetAll().ToArray(),
                user1,
                user2);

            return(shortestPathId.Reverse()
                   .Select(id => work.Users
                           .GetAll().FirstOrDefault(x => x.Id == id))
                   .ToList());
        }
Пример #2
0
        /// <summary>
        ///     Get mutual friends of two users
        /// </summary>
        /// <param name="user1">user1's id</param>
        /// <param name="user2">user2's id</param>
        /// <returns>Enumeration of mutual friends</returns>
        public IEnumerable <User> GetMutualFriends(Guid user1, Guid user2)
        {
            if (user1 == user2)
            {
                return(GetFriends(user1));
            }

            using (var work = new UnitOfWork())
            {
                var mutualFriendsArr = AnalyzerBridge.GetMutualFriends(
                    work.Connections.GetAll().ToArray(),
                    user1,
                    user2);

                return(mutualFriendsArr.Select(
                           friend => work.Users.GetAll()
                           .FirstOrDefault(x => x.Id == friend))
                       .ToList());
            }
        }