コード例 #1
0
        /// <summary>
        /// retorna vetor de áreas de pesquisa que serão usadas como vértices
        /// </summary>
        /// <param name="NumProfessor"></param>
        /// <returns> int[,] </returns>
        static public Vertex[] GetResearchAreaVector()
        {
            List <Student> students;

            int[,] matrix;

            students = IOOperations.PopulateStudentList();
            matrix   = IOOperations.PopulateMatrix();

            Vertex[] researchareas = new Vertex[counter];

            int x = 0;

            for (int i = x; i < researchareas.Length; i++) // Estrutura de repetição para percorrer todas áreas de pesquisa
            {
                var query = from student in students       // Linq para obter os estudantes de cada área de pesquisa
                            where student.ResearchField == i
                            select student;

                researchareas[i] = new Vertex(i);

                foreach (Student student in query)
                {
                    researchareas[i].students.Add(student);
                }
            }

            return(researchareas);
        }
コード例 #2
0
ファイル: Graph.cs プロジェクト: giorgecaique/TP_GRAFOS
        /// <summary>
        /// Preenche a matriz de arestas
        /// </summary>
        public void PopulateEdges()
        {
            int[,] temp = IOOperations.PopulateMatrix(); // Arquivo temporário

            int counter = 0;

            for (int i = 0; i < vertex.Length; i++)
            {
                for (int j = 0; j < vertex.Length; j++)
                {
                    Edge tempEdge = new Edge();
                    tempEdge.Weight     = temp[i, j]; // Adiciona o peso da aresta
                    tempEdge.borders[0] = vertex[i];  // Adiciona o vértice de uma borda
                    tempEdge.borders[1] = vertex[j];  // Adiciona o vértice da outra borda
                    edges.Add(tempEdge);
                    counter++;
                }
            }
        }