Beispiel #1
0
        // helper function to calculate the Triads
        private void newerCalc(Matrix s) // as of 12/18/12
        {
            triads = new List <Triad>();
            for (int i = 0; i < _count; i++)
            {
                // create and initialize a marked list to keep track of
                // which nodes have already been computed
                List <int>[] markedList = new List <int> [_count];
                for (int j = 0; j < _count; j++)
                {
                    markedList[j] = new List <int>();
                }

                int   totalTriangles = 0;
                Triad tri            = new Triad(i);

                for (int j = 0; j < triangleList[i].Count; j++)
                {
                    // assign secondNode to the current jth node in the triangleList
                    int secondNode = triangleList[i][j];
                    for (int k = 0; k < triangleList[secondNode].Count; k++)
                    {
                        int lastNode = triangleList[secondNode][k];
                        // need to check if i == j and if triad is a multiple
                        if (lastNode != i && !(markedList[lastNode].Contains(secondNode)))
                        {
                            if (triangleList[i].Contains(lastNode))
                            {
                                // triad is found so corresponding dyad nodes are added
                                // to the current triad
                                tri.AddDyad(secondNode, lastNode);

                                // mark the secondNode as having a triad consisting of
                                // the last node to avoid multiple triads
                                markedList[secondNode].Add(lastNode);
                                //triangleCount++; // number of actual triangles that contribute to t_i_jk
                            }
                            totalTriangles++;
                        }
                    }
                }
                localTransitivity[i] = (double)tri.Count / (double)totalTriangles;
                triads.Add(tri);
            }
        }
Beispiel #2
0
        // as of 12/18/12
        // helper function to calculate the Triads
        private void newerCalc(Matrix s)
        {
            triads = new List<Triad>();
            for (int i = 0; i < _count; i++)
            {
                // create and initialize a marked list to keep track of
                // which nodes have already been computed
                List<int>[] markedList = new List<int>[_count];
                for (int j = 0; j < _count; j++)
                    markedList[j] = new List<int>();

                int totalTriangles = 0;
                Triad tri = new Triad(i);

                for (int j = 0; j < triangleList[i].Count; j++)
                {
                    // assign secondNode to the current jth node in the triangleList
                    int secondNode = triangleList[i][j];
                    for (int k = 0; k < triangleList[secondNode].Count; k++)
                    {
                        int lastNode = triangleList[secondNode][k];
                        // need to check if i == j and if triad is a multiple
                        if (lastNode != i && !(markedList[lastNode].Contains(secondNode)))
                        {
                            if (triangleList[i].Contains(lastNode))
                            {
                                // triad is found so corresponding dyad nodes are added
                                // to the current triad
                                tri.AddDyad(secondNode, lastNode);

                                // mark the secondNode as having a triad consisting of
                                // the last node to avoid multiple triads
                                markedList[secondNode].Add(lastNode);
                                //triangleCount++; // number of actual triangles that contribute to t_i_jk
                            }
                            totalTriangles++;
                        }
                    }
                }
                localTransitivity[i] = (double)tri.Count / (double)totalTriangles;
                triads.Add(tri);
            }
        }