Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.*;
- import java.io.*;
- public class Graph {
- public final int n;
- public List<Edge>[] nodeEdges;
- public Graph(int n) {
- this.n = n; //конструктор
- nodeEdges = new List[n];
- for (int i = 0; i < n; i++) {
- nodeEdges[i] = new ArrayList<Edge>();
- }
- }
- void addEdge(int s, int t, int cost) {
- nodeEdges[s].add(new Edge(s, t, cost));
- }
- }
Add Comment
Please, Sign In to add comment