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
| import java.lang.Integer;
import java.util.*;
public class tp8_Exo4{
public static interface GraphOrienteSimple {
public void ajouterSommet( int i );
public void ajouterArrete( int i, int j );
public void supprimerSommet( int i);
public void supprimerArete( int i, int j);
public List obtenirVoisin( int i );
}
public static class Graph implements GraphOrienteSimple{
LinkedList<Integer> sommets;
Hashtable< Integer,LinkedList<Integer> > table;
Graph(){
sommets = new LinkedList<Integer>();
table = new Hashtable< Integer,LinkedList<Integer> >();
}
public void ajouterSommet( int i ){
sommets.add( new Integer(i) );
}
public void ajouterArrete( int i, int j ){
// table.put(i,j);
}
public void supprimerSommet( int i){
sommets.remove( new Integer(i) );
}
public void supprimerArete( int i, int j){
/*
if(isEmpty(table)){
System.out.println("table vide");
}
if( table.containsKey(i)){
if( table.containsKey(j) ){
table.remove(i,j);
}
}else{
System.out.println("cette arete n'existe pas");
}
*/
}
public List obtenirVoisin( int i ){
return new LinkedList();
}
}
public static void main (String[] args){
GraphOrienteSimple g = new Graph();
g.ajouterSommet(1);
g.ajouterSommet(2); |
Partager