Mon graphique est représenté par une matrice d'adjacence et je veux construire une méthode qui peut ajouter une matrice [M x N] à un bord choisi. Qu'est-ce qui manque ou qui ne va pas dans mon code? Notez que le graphique est acyclique.Graphes en Java - Comment attacher une matrice à une arête?
public class Graph {
/** Class Graph attributes */
int [][] grafoo;
/** Constructor */
public Graph (int dim)
{
grafoo = new int [dim][dim];
int i=0, j;
while(i<dim)
{
j=0;
while(j<dim)
{
grafoo[i][j]=0;
j++;
}
i++;
}
}
/** Method add_edge */ //receives two nodes and places to the graph an edge from one node to another with a matrix MxN (for example M=4 and N=5).
void add_edge(int i, int j) // my problem is at this part, representing an edge through a matrix instead of the number 1(usual to say there is a edge in a matrix of adjacency)
{
int[][] E = new int[M][N];
grafoo[i][j]= E;
}
Votre graphique a-t-il pondéré les bords? – fabian
Oui, il a, le poids est l'un des paramètres de la matrice que je dois mettre sur le bord. – user8885
Vous devriez ** certainement ** considérer une représentation alternative pour cela. Je pense qu'il devrait y avoir au moins une sorte de classe 'Edge' ... – Marco13