-
Notifications
You must be signed in to change notification settings - Fork 0
/
Node.java
72 lines (69 loc) · 949 Bytes
/
Node.java
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import java.util.*;
import java.lang.*;
import java.io.*;
public class Node
{
int visited = 0;
List<Integer> edges;
int deg;
int topovisited = 0;
public Node()
{
this.edges = new ArrayList<>();
this.deg = 0;
}
public Node( List<Integer> list)
{
this.edges = list;
this.deg = 0;
// /this.c = 0;
}
public int isVisited()
{
return visited;
}
public int isTopoVisited()
{
return topovisited;
}
public List<Integer> getList()
{
return edges;
}
public void setVisited(int a)
{
visited = a;
}
public void setTopoVisited(int a)
{
topovisited = a;
}
public void incrementdeg()
{
deg++;
}
public void incrementlist(int x)
{
edges.add(x);
}
public void decrementdeg()
{
deg--;
}
public int getDeg()
{
return deg;
}
public int containsElement(int x)
{
if(edges.size()!=0)
{
for(int i=0; i<edges.size(); i++)
{
if(edges.get(i) == x)
return 1;
}
}
return 0;
}
}