Advertisement
rfop

Grafico

May 1st, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. package lista6;
  2. import java.util.*;
  3. import java.lang.*;
  4. import java.io.*;
  5. public class Sendingemail {
  6.  
  7.  
  8. public static void main(String[] args) {
  9. Scanner in = new Scanner(System.in);
  10. int n=in.nextInt();
  11. List<Aresta>[] vertices = new ArrayList[n]<>;
  12. int m=in.nextInt();
  13. for(int i=0; i<m; i++) {
  14. int vertice1=in.nextInt();
  15. int vertice2=in.nextInt();
  16. int pesoAresta=in.nextInt();
  17. if(vertices[vertice1] == null) {
  18. vertices[vertice1] = new ArrayList<Vertice>();
  19. }
  20. if(vertices[vertice2] == null) {
  21. vertices[vertice2] = new ArrayList<Vertice>();
  22. }
  23. vertices[vertice1].add(new Aresta(vertice2,pesoAresta));
  24. }
  25.  
  26.  
  27.  
  28.  
  29. }
  30.  
  31.  
  32. }
  33. class Aresta{
  34. int a,peso;
  35.  
  36. public Aresta(int a,int peso) {
  37. this.a=a;
  38. this.peso=peso;
  39. }
  40. }
  41. class Vertice{
  42. int pos,cost;
  43.  
  44. public Vertice(int pos, int cos) {
  45. this.pos=pos;
  46. this.cost=cos;
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement