Graphe orienté à arêtes simples
Bonjour,je dois implémenter un graphe orienté à arêtes simples.
Voici mon code:
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 36 37 38 39 40 41 42 43 44 45 46
| import java.lang.*;
import java.util.*;
public class graphe081209{
public static class GraphOrienteSimple {
public interface GraphOrienteSimple {
LinkedList<String> l = new LinkedList<String>();
Hashtable<LinkedList<String>,int> table = new Hashtable<int,int>();
public void ajouterSommet( int i ){
l.add(i);
this.l=l;
}
public void ajouterArrete( int i, int j ){
table.put(i,j);
}
public void supprimerSommet( int i){
l.remove(i);
}
public void supprimerArete( int i, int j){
if(isEmpty(table)){
System.out.println("table vide");
}
if(containsKey(i)){
if(containsKey(j)){
table.remove(i,j);
}
}
else{
system.out.println("cette arete n'existe pas");
}
}
}
public static void main (String[] args){
ajouterSommet(1);
ajouterArete(1,2);
supprimerSommet(2);
supprimerArete(1,4);
}
}
} |
Mais j'ai pas mal d'erreur,dont voici la liste,je ne comprends pas,merci pour votre aide.
Erreur 1 que j'ai plusieur fois:
graphe.java:14: interface methods cannot have body
public void ajouterSommet( int i ){
Erreur 2 que j'ai plusieur fois:
graphe.java:43: cannot find symbol
symbol : method ajouterSommet(int)
location: class tp8_Exo4.GraphOrienteSimple
ajouterSommet(1);