示例#1
0
        static int[,] GenerateAdjMatrix(StudentsByLecture studentsByLecture)
        {
            int n = studentsByLecture.Keys.Count;

            int[,] matrix = new int[n, n];

            var lectures = studentsByLecture.Keys.ToList();

            for (int i = 0; i < lectures.Count - 1; i++)
            {
                var lectureAName     = lectures[i];
                var lectureAStudents = studentsByLecture[lectureAName];

                for (int j = i + 1; j < lectures.Count; j++)
                {
                    var lectureBName     = lectures[j];
                    var lectureBStudents = studentsByLecture[lectureBName];

                    if (Program.HasCommonMember(lectureAStudents, lectureBStudents))
                    {
                        matrix[i, j] = 1;
                        matrix[j, i] = 1;
                    }
                }
            }

            return(matrix);
        }
示例#2
0
        public void Calculate(string dataPath, string indexFile)
        {
            DATA_PATH  = dataPath;
            INDEX_FILE = indexFile;

            studentsByLecture = GetStudents();
            adjMatrix         = GenerateAdjMatrix(studentsByLecture);

            (var colorCount, var lectureColors) = ColorGraph(adjMatrix);
            calculatedColorCount    = colorCount;
            calculatedLectureColors = lectureColors;
        }
示例#3
0
        static StudentsByLecture GetStudents()
        {
            var lectures          = Program.ReadFile("Lectures");
            var studentsByLecture = new StudentsByLecture();

            foreach (var lecture in lectures)
            {
                studentsByLecture[lecture] = Program.ReadFile(lecture);
            }

            return(studentsByLecture);
        }
示例#4
0
        StudentsByLecture GetStudents()
        {
            lectures = ReadFile(INDEX_FILE).ToArray();
            var studentsByLecture = new StudentsByLecture();

            foreach (var lecture in lectures)
            {
                studentsByLecture[lecture] = ReadFile(lecture);
            }

            return(studentsByLecture);
        }