public User(string username, int id, ModuloIAProlog.ModuloIaClient prologService,int numTagsTotal) { double minraio = 3; double maxraio = 7.5; Id = id; Username = username; Profile = Graphs4Social_AR.User.LoadProfileByUser(username); IList<Graphs4Social_AR.Tag> tagList = Graphs4Social_AR.Tag.LoadAllByUsername(username); Tags = new List<string>(); foreach (Graphs4Social_AR.Tag tag in tagList) { Tags.Add(tag.Nome); } Z = Convert.ToDouble(prologService.tamanhoRede(2, Username)); // int numTags = Tags.Count; // Raio = minraio + ((maxraio - minraio) * (Convert.ToDouble(numTags) / Convert.ToDouble(numTagsTotal))); }
public static IList<Ligacao> trataListas(IList<string> ligacoes1, string username, ModuloIAProlog.ModuloIaClient prologService, int numTagsTotal) { IList<string> ligacoes = new List<string>(); IList<string> tags = new List<string>(); foreach (string lig in ligacoes1) { if (!lig.Equals("")) { ligacoes.Add(lig); } } IList<User> users = new List<User>(); IList<string> usernames = new List<string>(); IList<Ligacao> ligacoesRetornadas = new List<Ligacao>(); IList<Ligacao> ligacoesDirectas = new List<Ligacao>(); users.Add(new User(username,0,prologService,numTagsTotal)); usernames.Add(username); int id = 1; for(int k=0;k<ligacoes.Count-1;k=k+3) { if (!usernames.Contains(ligacoes[k + 1])) { usernames.Add(ligacoes[k + 1]); users.Add(new User(ligacoes[k + 1], id, prologService, numTagsTotal)); id++; } if (usernames.IndexOf(ligacoes[k]) == 0) { ligacoesDirectas.Add(new Ligacao(users[0], users[usernames.IndexOf(ligacoes[k + 1])], Convert.ToInt32(ligacoes[k + 2]))); } else { ligacoesRetornadas.Add(new Ligacao(users[usernames.IndexOf(ligacoes[k])], users[usernames.IndexOf(ligacoes[k + 1])], Convert.ToInt32(ligacoes[k + 2]))); } } Ligacao aux; // Depois fazemos sort for(int i = 0;i< ligacoesDirectas.Count-1; i++) { if(ligacoesDirectas[i].Forca < ligacoesDirectas[i+1].Forca){ aux = ligacoesDirectas[i]; ligacoesDirectas[i] = ligacoesDirectas[i + 1]; ligacoesDirectas[i + 1] = aux; i = 0; } } Ligacao[] arraytemp = new Ligacao[ligacoesDirectas.Count+ligacoesRetornadas.Count]; ligacoesDirectas.CopyTo(arraytemp, 0); ligacoesRetornadas.CopyTo(arraytemp, ligacoesDirectas.Count); ligacoesRetornadas = arraytemp.ToList(); ligacoesDirectas = new List<Ligacao>(); foreach (Ligacao lig in ligacoesRetornadas) { if (lig.User2.Id > lig.User1.Id) { ligacoesDirectas.Add(lig); } } return ligacoesDirectas; }