Lusien_Lashans

Dijkstra Graph

May 2nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.46 KB | None | 0 0
  1. package com.company;
  2. import java.util.*;
  3. import java.io.*;
  4.  
  5. public  class Graph {
  6.     public final int n;
  7.     public List<Edge>[] nodeEdges;
  8.  
  9.     public Graph(int n) {
  10.         this.n = n; //конструктор
  11.         nodeEdges = new List[n];
  12.         for (int i = 0; i < n; i++) {
  13.             nodeEdges[i] = new ArrayList<Edge>();
  14.         }
  15.     }
  16.  
  17.     void addEdge(int s, int t, int cost) {
  18.         nodeEdges[s].add(new Edge(s, t, cost));
  19.     }
  20. }
Add Comment
Please, Sign In to add comment