示例#1
0
        /* для хранения перестановок: ярусы 1..staff.length
         *                            выборки 1..C_{staff.length}*/

        public KnowlegePattern(List <string> staff, InputGraph G)
        {
            this.staff = new List <string> ();
            this.G     = G;

            foreach (string s in staff)
            {
                this.staff.Add(s);
            }
            this.vertexWeight = G.vertexWeight;
            this.edgeWeight   = edgeWeight;
            this.create_structure();
        }
示例#2
0
        public SocialNetwork(InputGraph G, List <string> url_for_KP)
        {
            this.G = G;

            departments         = new List <List <string> > ();
            edgeWeight          = new Dictionary <Edge <KnowlegePattern>, List <string> > ();
            KnowlegePattern_net = new List <KnowlegePattern> ();
            SocGraphWithKP      = new AdjacencyGraph <KnowlegePattern, Edge <KnowlegePattern> >();

            // G_KP --- полные подграфы
            // KP-LIST --- сгенерированные отделы
            // Заполняем список отделов
            List <InputGraph> G_KP = new List <InputGraph>(url_for_KP.Count);

            KnowlegePattern_net = new List <KnowlegePattern>(url_for_KP.Count);

            int           j = 0;
            List <string> vertex_list;

            foreach (string s in url_for_KP)
            {
                G_KP.Add(new InputGraph(s));
                vertex_list = new List <string> ();



                foreach (string department in G_KP[j].social_graph.Vertices)
                {
                    vertex_list.Add(department);
                }

                departments.Add(vertex_list);


                KnowlegePattern_net.Add(new KnowlegePattern(vertex_list, G_KP[j]));
                j++;
            }

            // заполняем SocGraph
            for (int i = 0; i < KnowlegePattern_net.Count; i++)
            {
                SocGraphWithKP.AddVertex(KnowlegePattern_net[i]);
            }


            // заполняем всевозможные связи между отделами
            List <string> first_find_matches  = new List <string>();
            List <string> second_find_matches = new List <string>();
            List <string> found = new List <string> ();

            for (int i = 0; i < KnowlegePattern_net.Count; i++)
            {
                for (int k = i; k < KnowlegePattern_net.Count; k++)
                {
                    //first_find_matches = new string[KnowlegePattern_net [i].G.social_graph.VertexCount];
                    foreach (string vert_i in KnowlegePattern_net[i].G.social_graph.Vertices)
                    {
                        first_find_matches.Add(vert_i);
                    }
                    foreach (string vert_k in KnowlegePattern_net[k].G.social_graph.Vertices)
                    {
                        first_find_matches.Add(vert_k);
                    }
                    // get list of users in both KP
                    for (int a = 0; a < first_find_matches.Count; a++)
                    {
                        for (int b = 0; b < second_find_matches.Count; b++)
                        {
                            if ((first_find_matches [a] == second_find_matches [b]) && (!found.Contains(first_find_matches [a])))
                            {
                                found.Add(first_find_matches [a]);
                            }

                            //добавление дуги
                            if (found.Count > 0)
                            {
                                Edge <KnowlegePattern> e = new Edge <KnowlegePattern> (KnowlegePattern_net [i], KnowlegePattern_net [k]);
                                if (!SocGraphWithKP.ContainsEdge(e))
                                {
                                    SocGraphWithKP.AddEdge(e);
                                    edgeWeight.Add(e, found);
                                }
                            }
                        }
                    }
                }
            }
        }