Advertisement
Guest User

Vertex

a guest
May 25th, 2015
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1. public class Vertex
  2. {
  3.     String name; //nazwa miasta
  4.     int id; //identyfikator miasta
  5.     HashMap<Vertex, Integer> list; //lista krawędzi, którymi można poruszać się z wierzchołka
  6.    
  7.     Vertex(String name)
  8.     {
  9.         this.name = name;
  10.         this.list = new HashMap<Vertex, Integer>();
  11.         this.id = 0;
  12.     }
  13.    
  14.     Vertex(int id)
  15.     {
  16.         this.id = id;
  17.         this.list = new HashMap<Vertex, Integer>();
  18.         this.name = "";
  19.     }
  20.    
  21.     void printVertex()
  22.     {
  23.         System.out.print(name+" "+id+": ");
  24.         for(Vertex key: list.keySet())
  25.         {
  26.             System.out.print(key.id+" ");
  27.         }
  28.         System.out.println();
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement