Relier des points par des lignes
Bonjour,
je demande votre aide car je suis bloqué : j'ai un rectangle de 64*32 points (Nodes), et je dois relier ces points par des lignes (Edge)
(Une petite difficulté s'ajoute car il y a certains points qu'il ne faut pas relier, mais mon problème ne réside pas là)
J'ai donc parcouru ce tableau 2 dimensions avec des boucles, comme ceci :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| for ( int i = 0; i < arrayLvl.length; i++ ) { // On créé les noeuds
for ( int j = 0; j < arrayLvl[i].length; j++ ) {
if ( arrayLvl[i][j] == 0 ) { // 0 équivaut à un espace disponnible
Vertex location = new Vertex( "Node_" + i + ";" + j, "Node_" + i + ";" + j );
nodes.add( location );
}
}
}
for ( int i = 0; i < arrayLvl.length; i++ ) { // On relie horizontalement les noeuds
for ( int j = 0; j < arrayLvl[i].length - 1; j++ ) {
if ( arrayLvl[i][j] == 0 && arrayLvl[i][j + 1] == 0 ) { // 0 équivaut à un espace disponnible
addLane( "Edge_ " + i + ";" + j, i, j, 10 );
}
}
} |
Edge.java :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| public class Edge {
private final String id;
private final Vertex source;
private final Vertex destination;
private final int weight;
public Edge( String id, Vertex source, Vertex destination, int weight ) {
this.id = id;
this.source = source;
this.destination = destination;
this.weight = weight;
}
public String getId() {
return id;
}
public Vertex getDestination() {
return destination;
}
public Vertex getSource() {
return source;
}
public int getWeight() {
return weight;
}
@Override
public String toString() {
return source + " " + destination;
}
} |
Or je n'ai aucune idée de comment relier verticalement les noeuds :/ j'ai essayer avec le double for, sauf que je bloque
Pouvez vous m'aider svp ? merci !!!!! :)