Beispiel #1
0
        public void dfsrecommend(string s)
        {
            int  aktif      = this.searchIdxNode(s);
            node node_aktif = this.nodes[aktif];
            //copy adj
            graph adj_aktif = new graph();

            foreach (node i in node_aktif.adjacent)
            {
                adj_aktif.addNode(i);
            }
            graph friend_recommend = new graph();

            foreach (node i in this.nodes)
            {
                node temp = new node(i.vertex);
                if (temp.vertex != node_aktif.vertex && (!adj_aktif.contain(temp.vertex)))
                {
                    friend_recommend.addNode(temp);
                }
                foreach (node j in i.adjacent)
                {
                    int num = adj_aktif.searchIdxNode(j.vertex);
                    if (num != -1)
                    {
                        temp.addAdj(adj_aktif.nodes[num]);
                    }
                }
            }
            friend_recommend.AllInfo();
        }
Beispiel #2
0
        public void dfsrecommend(string s, RichTextBox rtb)
        {
            graph g = new graph();

            foreach (node i in this.nodes)
            {
                g.addNode(i);
            }
            int  aktif      = g.searchIdxNode(s);
            node node_aktif = g.nodes[aktif];
            //copy adj
            graph adj_aktif = new graph();

            foreach (node i in node_aktif.adjacent)
            {
                adj_aktif.addNode(i);
            }
            graph friend_recommend = new graph();

            foreach (node i in g.nodes)
            {
                node temp = new node(i.vertex);
                if (temp.vertex != node_aktif.vertex && (!adj_aktif.contain(temp.vertex)))
                {
                    friend_recommend.addNode(temp);
                }
                foreach (node j in i.adjacent)
                {
                    int num = adj_aktif.searchIdxNode(j.vertex);
                    if (num != -1)
                    {
                        temp.addAdj(adj_aktif.nodes[num]);
                    }
                }
            }
            rtb.AppendText("Daftar rekomendasi teman untuk akun " + s + ":\n");
            Boolean HasRecom = false;

            foreach (node i in friend_recommend.nodes)
            {
                if (i.adjCount() > 0)
                {
                    HasRecom = true;
                }
            }
            if (HasRecom)
            {
                friend_recommend.sortGraphDescAdjCount();
                friend_recommend.AllInfo(rtb);
            }
            else
            {
                rtb.AppendText("Tidak ada yang cocok.\n");
            }
        }