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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
import java.util.*;
public class DetectionCircuitsGraphe {
public static void main(String[] args) {
// TODO Auto-generated method stub
Vertice v1= new Vertice();
Vertice v2=new Vertice();
Vertice v3 =new Vertice();
v1.addFollower(v2,0);
v1.addFollower(v3,1);
v2.addFollower(v3, 0);
FollowersArray Dictionnaire= new FollowersArray(v1);
FollowersArray.addVertice(v2);
FollowersArray.addVertice(v3);
for(int i=0;i <= FollowersArray.Followers.length;i++){
for (int j=0;j <= FollowersArray.Followers[i].length;j++){
if (FollowersArray.Followers[i][0]==null){
FollowersArray.Followers[i]=null;
}
}
}
}
}
class Vertice{
int ref;
Vertice Followers [];
void addFollower(Vertice follower, int ref){
Followers[ref]=follower;
}
}
class FollowersArray{
static int refVertice;
static int ref=0;
static Vertice Followers [][];
FollowersArray(Vertice v){
refVertice=++ref;
Followers[refVertice][0]=v;
for(int i=0;i< v.Followers.length;i++){
Followers[refVertice][i]=v.Followers[i];
}
}
static void addVertice(Vertice v){
refVertice=++ref;
Followers[refVertice][0]=v;
for(int i=0;i< v.Followers.length;i++){
Followers[refVertice][i]=v.Followers[i];
}
}
} |
Partager