Esempio n. 1
0
 public clique(Clique L)
 {
     num_networks = 1;
     data = new List<byte>(L.MemberRangeSize);
     for (int i = 0; i < L.MemberRangeSize; i++)
     {
         data.Add((byte)(L.Contains(i) ? 1 : 0));
         //size += L[i];
         size += (L.Contains(i) ? 1 : 0);
     }
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="DataStructures.Graphs.CliqueGraph`1"/> class.
        /// Copies the model from another graph.
        /// </summary>
        /// <param name="graph">Graph.</param>
        public CliqueGraph(IGraph <T> graph)
            : this(graph.Vertices)
        {
            foreach (var startVert in Vertices)
            {
                foreach (var endVert in graph.Neighbours(startVert))
                {
                    if (!HasEdge(startVert, endVert))
                    {
                        // Add vortex
                        Clique newClan = new Clique();
                        newClan.Add(startVert);
                        newClan.Add(endVert);

                        ExpandToMaximal(graph, newClan);
                        _cliques.Add(newClan);
                    }
                }
            }
        }
Esempio n. 3
0
        public override void main()
        {
            IStringInstance input_data_instance = (IStringInstance)Input_data.Instance;

            input_data_instance.Value = readInput();

            long t0 = (long)(DateTime.UtcNow - (new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc))).TotalMilliseconds;

            Clique.go();
            long t1 = (long)(DateTime.UtcNow - (new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc))).TotalMilliseconds;

            IIteratorInstance <IKVPair <IString, ICliqueNode> > output_data_instance = (IIteratorInstance <IKVPair <IString, ICliqueNode> >)Output_data.Instance;
            int    sum = 0;
            object o;

            while (output_data_instance.fetch_next(out o))
            {
                IKVPairInstance <IString, ICliqueNode> KMV = (IKVPairInstance <IString, ICliqueNode>)o;
                IStringInstance     pivo       = (IStringInstance)KMV.Key;
                ICliqueNodeInstance cliqueNode = (ICliqueNodeInstance)KMV.Value;
                sum += cliqueNode.IdInstance;
            }
            clearWriteFile("./outCliqueApp", "Soma:" + sum + "Tempo:" + (t1 - t0));
        }
 /* (non-Javadoc)
  * @see edu.stanford.nlp.sequences.FeatureFactory#getCliqueFeatures(edu.stanford.nlp.util.PaddedList, int, edu.stanford.nlp.sequences.Clique)
  */
 public override ICollection GetCliqueFeatures(PaddedList info, int position, Clique clique)
 {
     // TODO Auto-generated method stub
     return(null);
 }
        public override ICollection <string> GetCliqueFeatures(PaddedList <CoreLabel> info, int position, Clique clique)
        {
            ICollection <string> features = new HashSet <string>();

            foreach (CoreLabel l in info)
            {
                for (int i = 0; i < 10; i++)
                {
                    features.Add("feat" + i + ":" + l.Word());
                }
            }
            return(features);
        }
Esempio n. 6
0
        public void ComputeNP(Matrix WCA, Matrix CCA, int node, int n, List <List <int> > Blocks, CliqueCollection _cliques, List <int[]> communities, int comNum, bool isComm, bool isClique, Matrix Cohesion, List <double> tempattribute, bool file)
        {
            if (!isClique && !isComm)
            {
                for (int col = 0; col < Blocks.Count; col++)
                {
                    if (WCA[node, col] != 0 && (WCA[n + 1, col] >= CCA[n + 1, col]))
                    {
                        List <int> rcalist   = new List <int>();
                        List <int> rccalist  = new List <int>();
                        List <int> rccalist2 = new List <int>();
                        for (int row = 0; row < n; row++)
                        {
                            if (Blocks[col].Contains(row) && row != node)
                            {
                                rcalist.Add(row);
                            }
                        }
                        Clique rcaclique = new Clique(rcalist, n);
                        rcaclique.ComputeCohesion(Cohesion);
                        double rcawsum = rcaclique.ComputeWsum(tempattribute, file);
                        for (int row = 0; row < n; row++)
                        {
                            if (!Blocks[col].Contains(row) || row == node)
                            {
                                rccalist.Add(row);
                            }
                            if (!Blocks[col].Contains(row))
                            {
                                rccalist2.Add(row);
                            }
                        }
                        Clique rccaclique = new Clique(rccalist, n);
                        rccaclique.ComputeCohesion(Cohesion);
                        double rccawsum    = rccaclique.ComputeWsum(tempattribute, file);
                        Clique rccaclique2 = new Clique(rccalist2, n);
                        rccaclique2.ComputeCohesion(Cohesion);
                        double rccawsum2 = rccaclique2.ComputeWsum(tempattribute, file);

                        if (rcawsum < rccawsum)
                        {
                            np += 1;
                        }
                        else if (rcawsum == rccawsum)
                        {
                            np += 0.5;
                        }
                        if (rcawsum < rccawsum2)
                        {
                            npabs += 1;
                        }
                        else if (rcawsum == rccawsum2)
                        {
                            npabs += 0.5;
                        }
                    }
                }
            }//if block
            else if (isComm)
            {
                for (int col = 0; col < comNum; col++)
                {
                    if (WCA[node, col] != 0 && (WCA[n + 1, col] >= CCA[n + 1, col]))
                    {
                        List <int> rcalist   = new List <int>();
                        List <int> rccalist  = new List <int>();
                        List <int> rccalist2 = new List <int>();
                        // recreate the WCA matrix without the members of the node
                        for (int row = 0; row < n; row++)
                        {
                            if ((communities[col][row] != 0) && (row != node))
                            {
                                rcalist.Add(row);
                            }
                        }
                        Clique rcaclique = new Clique(rcalist, n);
                        rcaclique.ComputeCohesion(Cohesion);

                        double rcawsum = rcaclique.ComputeWsum(tempattribute, file);
                        // recreate the CCA matrix with the members that were removed
                        // from the WCA matrix previously
                        for (int row = 0; row < n; row++)
                        {
                            if ((communities[col][row] == 0) || (row == node))
                            {
                                rccalist.Add(row);
                            }
                            if (communities[col][row] == 0)
                            {
                                rccalist2.Add(row);
                            }
                        }
                        Clique rccaclique = new Clique(rccalist, n);
                        rccaclique.ComputeCohesion(Cohesion);
                        double rccawsum    = rccaclique.ComputeWsum(tempattribute, file);
                        Clique rccaclique2 = new Clique(rccalist2, n);
                        rccaclique2.ComputeCohesion(Cohesion);
                        double rccawsum2 = rccaclique2.ComputeWsum(tempattribute, file);

                        if (rcawsum < rccawsum)
                        {
                            np += 1;
                        }
                        else if (rcawsum == rccawsum)
                        {
                            np += 0.5;
                        }
                        if (rcawsum < rccawsum2)
                        {
                            npabs += 1;
                        }
                        else if (rcawsum == rccawsum2)
                        {
                            npabs += 0.5;
                        }
                    }
                }
            }
            else //if use clique
            {
                for (int col = 0; col < _cliques.Count; col++)
                {
                    if (WCA[node, col] != 0 && (WCA[n + 1, col] >= CCA[n + 1, col]))
                    {
                        List <int> rcalist   = new List <int>();
                        List <int> rccalist  = new List <int>();
                        List <int> rccalist2 = new List <int>();
                        for (int row = 0; row < n; row++)
                        {
                            if (_cliques[col].Contains(row) && row != node)
                            {
                                rcalist.Add(row);
                            }
                        }
                        Clique rcaclique = new Clique(rcalist, n);
                        rcaclique.ComputeCohesion(Cohesion);
                        double rcawsum = rcaclique.ComputeWsum(tempattribute, file);
                        for (int row = 0; row < n; row++)
                        {
                            if (!_cliques[col].Contains(row) || row == node)
                            {
                                rccalist.Add(row);
                            }
                            if (!_cliques[col].Contains(row))
                            {
                                rccalist.Add(row);
                            }
                        }
                        Clique rccaclique = new Clique(rccalist, n);
                        rccaclique.ComputeCohesion(Cohesion);
                        double rccawsum    = rccaclique.ComputeWsum(tempattribute, file);
                        Clique rccaclique2 = new Clique(rccalist2, n);
                        rccaclique2.ComputeCohesion(Cohesion);
                        double rccawsum2 = rccaclique2.ComputeWsum(tempattribute, file);

                        if (rcawsum < rccawsum)
                        {
                            np += 1;
                        }
                        else if (rcawsum == rccawsum)
                        {
                            np += 0.5;
                        }
                        if (rcawsum < rccawsum2)
                        {
                            npabs += 1;
                        }
                        else if (rcawsum == rccawsum2)
                        {
                            npabs += 0.5;
                        }
                    }
                }
            }
        }
Esempio n. 7
0
 // input positive points to increase reputation, negative to decrease
 public void shiftReputation(Clique clique, int repPoints)
 {
     this.setReputation(clique, this.getReputation(clique) + repPoints);
 }
Esempio n. 8
0
 public void setReputation(Clique clique, int repPoints)
 {
     switch (clique)
     {
         case Clique.Nerd: nerdRep += repPoints; break;
         case Clique.Jock: jockRep += repPoints; break;
         case Clique.Prep: prepRep += repPoints; break;
         case Clique.Bully: bullyRep += repPoints; break;
         case Clique.Slacker: slackerRep += repPoints; break;
     }
 }
Esempio n. 9
0
 public int getReputation(Clique clique)
 {
     switch (clique)
     {
         case Clique.Nerd: return nerdRep;
         case Clique.Jock: return jockRep;
         case Clique.Prep: return prepRep;
         case Clique.Bully: return bullyRep;
         case Clique.Slacker: return slackerRep;
     }
     return 0;
 }
Esempio n. 10
0
 private void drawRepHelper(SpriteBatch sb, int offsetY, Clique clique)
 {
     if (this.isInFocus() || this.isSmoothMoving())  //i.e. can be seen on screen
     {
         Hero h1 = Hero.instance;
         string cliqueHeader = SunsetUtils.enumToString<Clique>(clique) + ":";
         int offsetNeedleX = h1.getReputation(clique);
         // we need some sort of scale for rep (min / max), needle will move accordingly
         // my idea is having a log(reputation) scale - it moves quickly at first, then slowly
         sb.DrawString(font, cliqueHeader,
             new Vector2(this.getX() + TEXT_X_OFFSET, offsetY - font.MeasureString(cliqueHeader).Y / 2), Color.Black);
         sb.Draw(barTexture, new Rectangle(this.getX() + BAR_X_OFFSET, offsetY - BAR_HEIGHT / 2,
             BAR_WIDTH, BAR_HEIGHT), Color.White);
         sb.Draw(needleTexture, new Rectangle(this.getX() + BAR_X_OFFSET + BAR_WIDTH / 2 + offsetNeedleX - NEEDLE_WIDTH / 2,
             offsetY - NEEDLE_HEIGHT / 2,
             NEEDLE_WIDTH, NEEDLE_HEIGHT), Color.White);
     }
 }
Esempio n. 11
0
 public void Go()
 {
     Clique.go();
 }
Esempio n. 12
0
        public void ComputeNP(Matrix WCA, Matrix CCA, int node, int n, List<List<int>> Blocks, CliqueCollection _cliques, List<int[]> communities, int comNum, bool isComm, bool isClique, Matrix Cohesion, List<double> tempattribute, bool file)
        {
            if (!isClique && !isComm)
            {
                for (int col = 0; col < Blocks.Count; col++)
                {
                    if (WCA[node, col] != 0 && (WCA[n + 1, col] >= CCA[n + 1, col]))
                    {
                        List<int> rcalist = new List<int>();
                        List<int> rccalist = new List<int>();
                        List<int> rccalist2 = new List<int>();
                        for (int row = 0; row < n; row++)
                            if (Blocks[col].Contains(row) && row != node)
                                rcalist.Add(row);
                        Clique rcaclique = new Clique(rcalist, n);
                        rcaclique.ComputeCohesion(Cohesion);
                        double rcawsum = rcaclique.ComputeWsum(tempattribute, file);
                        for (int row = 0; row < n; row++)
                        {
                            if (!Blocks[col].Contains(row) || row == node)
                                rccalist.Add(row);
                            if (!Blocks[col].Contains(row))
                                rccalist2.Add(row);
                        }
                        Clique rccaclique = new Clique(rccalist, n);
                        rccaclique.ComputeCohesion(Cohesion);
                        double rccawsum = rccaclique.ComputeWsum(tempattribute, file);
                        Clique rccaclique2 = new Clique(rccalist2, n);
                        rccaclique2.ComputeCohesion(Cohesion);
                        double rccawsum2 = rccaclique2.ComputeWsum(tempattribute, file);

                        if (rcawsum < rccawsum) np += 1;
                        else if (rcawsum == rccawsum) np += 0.5;
                        if (rcawsum < rccawsum2) npabs += 1;
                        else if (rcawsum == rccawsum2) npabs += 0.5;

                    }

                }
            }//if block
            else if (isComm)
            {
                for (int col = 0; col < comNum; col++)
                {
                    if (WCA[node, col] != 0 && (WCA[n + 1, col] >= CCA[n + 1, col]))
                    {
                        List<int> rcalist = new List<int>();
                        List<int> rccalist = new List<int>();
                        List<int> rccalist2 = new List<int>();
                        // recreate the WCA matrix without the members of the node
                        for (int row = 0; row < n; row++)
                            if ((communities[col][row] != 0) && (row != node))
                                rcalist.Add(row);
                        Clique rcaclique = new Clique(rcalist, n);
                        rcaclique.ComputeCohesion(Cohesion);

                        double rcawsum = rcaclique.ComputeWsum(tempattribute, file);
                        // recreate the CCA matrix with the members that were removed
                        // from the WCA matrix previously
                        for (int row = 0; row < n; row++)
                        {
                            if ((communities[col][row] == 0) || (row == node))
                                rccalist.Add(row);
                            if (communities[col][row] == 0)
                                rccalist2.Add(row);
                        }
                        Clique rccaclique = new Clique(rccalist, n);
                        rccaclique.ComputeCohesion(Cohesion);
                        double rccawsum = rccaclique.ComputeWsum(tempattribute, file);
                        Clique rccaclique2 = new Clique(rccalist2, n);
                        rccaclique2.ComputeCohesion(Cohesion);
                        double rccawsum2 = rccaclique2.ComputeWsum(tempattribute, file);

                        if (rcawsum < rccawsum) np += 1;
                        else if (rcawsum == rccawsum) np += 0.5;
                        if (rcawsum < rccawsum2) npabs += 1;
                        else if (rcawsum == rccawsum2) npabs += 0.5;

                    }
                }

            }
            else //if use clique
            {
                for (int col = 0; col < _cliques.Count; col++)
                {
                    if (WCA[node, col] != 0 && (WCA[n + 1, col] >= CCA[n + 1, col]))
                    {
                        List<int> rcalist = new List<int>();
                        List<int> rccalist = new List<int>();
                        List<int> rccalist2 = new List<int>();
                        for (int row = 0; row < n; row++)
                            if (_cliques[col].Contains(row) && row != node)
                                rcalist.Add(row);
                        Clique rcaclique = new Clique(rcalist, n);
                        rcaclique.ComputeCohesion(Cohesion);
                        double rcawsum = rcaclique.ComputeWsum(tempattribute, file);
                        for (int row = 0; row < n; row++)
                        {
                            if (!_cliques[col].Contains(row) || row == node)
                                rccalist.Add(row);
                            if (!_cliques[col].Contains(row))
                                rccalist.Add(row);
                        }
                        Clique rccaclique = new Clique(rccalist, n);
                        rccaclique.ComputeCohesion(Cohesion);
                        double rccawsum = rccaclique.ComputeWsum(tempattribute, file);
                        Clique rccaclique2 = new Clique(rccalist2, n);
                        rccaclique2.ComputeCohesion(Cohesion);
                        double rccawsum2 = rccaclique2.ComputeWsum(tempattribute, file);

                        if (rcawsum < rccawsum) np += 1;
                        else if (rcawsum == rccawsum) np += 0.5;
                        if (rcawsum < rccawsum2) npabs += 1;
                        else if (rcawsum == rccawsum2) npabs += 0.5;

                    }
                }
            }
        }
Esempio n. 13
0
        /// <summary>Extracts all the features from the input data at a certain index.</summary>
        /// <param name="cInfo">The complete data set as a List of WordInfo</param>
        /// <param name="loc">The index at which to extract features.</param>
        public override ICollection <string> GetCliqueFeatures(PaddedList <IN> cInfo, int loc, Clique clique)
        {
            ICollection <string> features = Generics.NewHashSet();

            if (clique == cliqueC)
            {
                AddAllInterningAndSuffixing(features, FeaturesC(cInfo, loc), "C");
            }
            else
            {
                if (clique == cliqueCpC)
                {
                    AddAllInterningAndSuffixing(features, FeaturesCpC(cInfo, loc), "CpC");
                    AddAllInterningAndSuffixing(features, FeaturesCnC(cInfo, loc - 1), "CnC");
                }
                else
                {
                    if (clique == cliqueCpCp2C)
                    {
                        AddAllInterningAndSuffixing(features, FeaturesCpCp2C(cInfo, loc), "CpCp2C");
                    }
                    else
                    {
                        if (clique == cliqueCpCp2Cp3C)
                        {
                            AddAllInterningAndSuffixing(features, FeaturesCpCp2Cp3C(cInfo, loc), "CpCp2Cp3C");
                        }
                    }
                }
            }
            if (Debug > 0)
            {
                EncodingPrintWriter.Err.Println("For " + cInfo[loc] + ", features: " + features, "UTF-8");
            }
            return(features);
        }
Esempio n. 14
0
        /// <summary>Extracts all the features from the input data at a certain index.</summary>
        /// <param name="cInfo">The complete data set as a List of WordInfo</param>
        /// <param name="loc">The index at which to extract features.</param>
        public override ICollection <string> GetCliqueFeatures(PaddedList <IN> cInfo, int loc, Clique clique)
        {
            ICollection <string> features = Generics.NewHashSet();

            if (clique == cliqueC)
            {
                AddAllInterningAndSuffixing(features, FeaturesC(cInfo, loc), "C");
            }
            else
            {
                if (clique == cliqueCpC)
                {
                    AddAllInterningAndSuffixing(features, FeaturesCpC(cInfo, loc), "CpC");
                    AddAllInterningAndSuffixing(features, FeaturesCnC(cInfo, loc - 1), "CnC");
                }
            }
            // else if (clique == cliqueCpCp2C) {
            //   addAllInterningAndSuffixing(features, featuresCpCp2C(cInfo, loc), "CpCp2C");
            // } else if (clique == cliqueCpCp2Cp3C) {
            //   addAllInterningAndSuffixing(features, featuresCpCp2Cp3C(cInfo, loc), "CpCp2Cp3C");
            // } else if (clique == cliqueCpCp2Cp3Cp4C) {
            //   addAllInterningAndSuffixing(features, featuresCpCp2Cp3Cp4C(cInfo, loc), "CpCp2Cp3Cp4C");
            // } else if (clique == cliqueCpCp2Cp3Cp4Cp5C) {
            //   addAllInterningAndSuffixing(features, featuresCpCp2Cp3Cp4Cp5C(cInfo, loc), "CpCp2Cp3Cp4Cp5C");
            // }
            return(features);
        }
Esempio n. 15
0
 int IComparable <Clique> .CompareTo(Clique other)
 {
     throw new NotImplementedException();
 }
Esempio n. 16
0
        /// <summary>Extracts all the features from the input data at a certain index.</summary>
        /// <param name="cInfo">The complete data set as a List of WordInfo</param>
        /// <param name="loc">The index at which to extract features.</param>
        public override ICollection <string> GetCliqueFeatures(PaddedList <In> cInfo, int loc, Clique clique)
        {
            ICollection <string> features = Generics.NewHashSet();

            if (clique == cliqueC)
            {
                AddAllInterningAndSuffixing(features, FeaturesC(cInfo, loc), "C");
            }
            else
            {
                if (clique == cliqueCpC)
                {
                    AddAllInterningAndSuffixing(features, FeaturesCpC(cInfo, loc), "CpC");
                }
                else
                {
                    if (clique == cliqueCp2C)
                    {
                        AddAllInterningAndSuffixing(features, FeaturesCp2C(cInfo, loc), "Cp2C");
                    }
                    else
                    {
                        if (clique == cliqueCp3C)
                        {
                            AddAllInterningAndSuffixing(features, FeaturesCp3C(cInfo, loc), "Cp3C");
                        }
                    }
                }
            }
            string domain = cInfo[loc].Get(typeof(CoreAnnotations.DomainAnnotation));

            if (domain != null)
            {
                ICollection <string> domainFeatures = Generics.NewHashSet();
                foreach (string feature in features)
                {
                    domainFeatures.Add(feature + DomainMarker + domain);
                }
                Sharpen.Collections.AddAll(features, domainFeatures);
            }
            return(features);
        }
Esempio n. 17
0
 public override void main()
 {
     Clique.go();
 }
Esempio n. 18
0
 public void setClique(Clique clique)
 {
     this.clique = clique;
 }