示例#1
0
文件: Neo.cs 项目: kzinti/MaxClique
 public void createUser(Friend newFriend)
 {
     client.Cypher
         .Create("(friend:Friend {newFriend})")
         .WithParam("newFriend", newFriend)
         .ExecuteWithoutResults();
 }
示例#2
0
文件: Form1.cs 项目: kzinti/MaxClique
        private void AddFriendToListView(Friend friend)
        {
            ListViewItem newItem = new ListViewItem(friend.Name);

            newItem.Tag = friend.ID;

            friendsListView.Items.Add(newItem);
        }
示例#3
0
文件: Neo.cs 项目: kzinti/MaxClique
 public void relateUsers(Friend fnd1, Friend fnd2)
 {
     client.Cypher
         .Match("(friend1:Friend)", "(friend2:Friend)")
         .Where((Friend friend1) => friend1.ID == fnd1.ID)
         .AndWhere((Friend friend2) => friend2.ID == fnd2.ID)
         .CreateUnique("friend1-[:FRIENDS_WITH]->friend2")
         .ExecuteWithoutResults();
 }
示例#4
0
文件: Neo.cs 项目: kzinti/MaxClique
 public dynamic numFriends(Friend usr)
 {
     var frndC = client.Cypher
         .OptionalMatch("(user:Friend)-[FRIENDS_WITH]-(friend:Friend)")
         .Where((Friend user) => user.ID == usr.ID)
         .Return((friend) => friend.Count() )
         .Results;
     int num = (int)frndC.ElementAt<long>(0);
     return num;
 }
示例#5
0
 public bool areFriends(Friend f1, Friend f2)
 {
     dynamic friendsTaskResult = fb.Get("/" + f1.ID + "/friends/" + f2.ID);
     var result = (IDictionary<string, object>)friendsTaskResult;
     var data = (IEnumerable<object>)result["data"];
     
     if (data.Count() > 0)
         return true;
     else
         return false;
 }
示例#6
0
文件: Neo.cs 项目: kzinti/MaxClique
 public dynamic getUserNFriends(Friend usr)
 {
     var usrWfrnd = client.Cypher
         .Match("(user:Friend)-[FRIENDS_WITH]-(friend:Friend)")
         .Where((Friend user) => user.ID == usr.ID)
         .Return((user, friend) => new {
             user = user.As<Friend>(),
             _friends = friend.CollectAs<Friend>()
         })
         .Results.ToList();
     //Friend[] fndary = new Friend[usrWfrnd.ElementAt(0)._friends.Count()];
     List<Friend> fndlst = new List<Friend>();
     if (usrWfrnd.ElementAt(0)._friends.Count() > 0)
     {
         foreach (var f in usrWfrnd.ElementAt(0)._friends)
         {
             fndlst.Add(f.Data);
         }
     }
     UserNFriends rtn = new UserNFriends { _friends = fndlst, user = usrWfrnd.ElementAt(0).user };
     return rtn;
 }
示例#7
0
文件: Neo.cs 项目: kzinti/MaxClique
 public void setLocalID(Friend usr, int localID)
 {
     client.Cypher
         .Match("(user:Friend)")
         .Where((Friend user) => user.ID == usr.ID)
         .Set("user.localID = {localID}")
         .WithParam("localID", localID)
         .ExecuteWithoutResults();
 }
示例#8
0
文件: Neo.cs 项目: kzinti/MaxClique
 internal bool friends(Friend f1, Friend f2)
 {
     var daFriends = client.Cypher
         .Match("(u1:Friend)", "(u2:Friend)")
         .Where((Friend u1) => u1.ID == f1.ID)
         .AndWhere((Friend u2) => u2.ID == f2.ID)
         .AndWhere("(u1)-[:FRIENDS_WITH]-(u2)")
         .Return((u1) => u1.As<Friend>())
         .Results;
     if (daFriends.Count() > 0)
         return true;
     else
         return false;
 }
示例#9
0
文件: Neo.cs 项目: kzinti/MaxClique
 public void setNumFriends(Friend usr, int numFriends)
 {
     client.Cypher
         .Match("(user:Friend)")
         .Where((Friend user) => user.ID == usr.ID)
         .Set("user.numFriends = {numFriends}")
         .WithParam("numFriends", numFriends)
         .ExecuteWithoutResults();
 }
示例#10
0
 async public void getFriendsList()
 {
     if (_authorized)
     {
         dynamic friendsTaskResult = await fb.GetTaskAsync("/me/friends");
         var results = (IDictionary<string, object>)friendsTaskResult;
         var data = (IEnumerable<object>)results["data"];
         foreach (var item in data)
         {
             var friend = (IDictionary<string, object>)item;
             Friend newFriend = new Friend
             {
                 Name = (string)friend["name"],
                 ID = (string)friend["id"]
             };
             _friends.Add(newFriend);
         }
     }
     else
     {
         MessageBox.Show("Not logged into Facebook!", "Not Currently Logged In", MessageBoxButtons.OK,
                         MessageBoxIcon.Error);
     }
 }
示例#11
0
 private bool frndInClique(Friend f1, Gene g)
 {
     for (int i = 0; i < g.bitString.Length; i++)
     {
         if (g.bitString[i] == true)
         {
             Friend f2 = _friends.First(f => f.localID == i);
             if (!neo.friends(f1, f2))
                 return false;
         }
     }
     return true;
 }