Ciao, ho bisogno di produrre una matrice di tipo:
Avendo come input nodeList che sarebbe una lista di nomi dei nodi, e una lista linkList che contiene le connesioni tra questi nodi. Linklist viene utilizzata per ricavare i nomi dei nodi client e supplier di tale connesione, per verificare tra quali nodi e presente o meno la connesione. Il mio problema e' che non mi stampa la matrice e non riesco a capire perche, dov'e il problema.codice:00 node1 node2 node3 node1 1 0 0 node2 0 0 1 node3 1 1 0
per piacere aiutatemi.codice://costruttore public AdjMatrix(EA.Repository repository,ArrayList nodeList, ArrayList linkList) { String[,] matrix; matrix = new String[nodeList.Count, nodeList.Count]; this.modelRepository = repository; //ArrayList result = new ArrayList(); using (StreamWriter writer = new StreamWriter("C:\\Users\\Martina\\Desktop\\matrix.txt")) { Console.SetOut(writer); //inizializzazione dei nomi delle classi for (int i = 0; i < nodeList.Count; i++) { if (i == 0) { matrix[i, 0] = (""); } else { foreach (EA.Element node in nodeList) { matrix[i, 0] = node.Name; } } } //inizializzazione dei valori della matrice for (int j = 0; j < nodeList.Count; j++) { if (j == 0) { matrix[0, j] = (""); } else { foreach (EA.Element node in nodeList) { matrix[0, j] = node.Name; } } } //definizione dell'esistenza del link foreach (EA.Connector link in linkList) { for (int i = 1; i < nodeList.Count; i++) { int supplier = link.SupplierID; int client = link.ClientID; String supplierNode = modelRepository.GetElementByID(supplier).Name; String clientNode = modelRepository.GetElementByID(client).Name; if (supplierNode.Equals(matrix[i, 0])) { for (int j = 1; j < nodeList.Count; j++) { if (clientNode.Equals(matrix[0, j])) { matrix[i, j] = "1"; } else { matrix[i, j] = "0"; } } } } } Console.WriteLine("matrix : "); for (int i = 0; i < nodeList.Count; i++) { for (int j = 0; j < nodeList.Count; j++) Console.Write(matrix[i, j] + "\t"); Console.WriteLine(); } } }
Grazie mille.
Defi

