-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNeighbor.cs
More file actions
37 lines (35 loc) · 1.08 KB
/
Neighbor.cs
File metadata and controls
37 lines (35 loc) · 1.08 KB
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
using System;
using System.IO;
using System.Net;
namespace DistanceVector {
public class Neighbor {
// Number of neighbors
public int n { get; set; }
// This neighbor id
public int id { get; set; }
// This neighbor ip
public IPAddress address { get; set; }
// This neighbor port
public int port { get; set; }
// This neighbor id table
public int[] dv { get; set; }
// This neighbors next neighbor
public int[] next { get; set; }
public const int INFINITY = int.MaxValue;
// Constructor:
public Neighbor(int n, int id, IPAddress address, int port, int[] dv) {
this.n = n;
this.id = id;
this.address = address;
this.port = port;
this.dv = dv;
next = new int[n];
for (int i = 0; i < n; i++) {
if (dv[i] > 0 && dv[i] < INFINITY)
next[i] = i;
else
next[i] = -1;
}
}
}
}