-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.java
More file actions
48 lines (37 loc) · 937 Bytes
/
Copy pathNode.java
File metadata and controls
48 lines (37 loc) · 937 Bytes
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
package networkAnalyse;
// Node class representing a single node.
public class Node {
private String name; // The name of the node
private int degree; // The degree of the node (i.e. number of edges)
// Default constructor that creates a node with an empty (string) name.
public Node(){
name = "";
degree = 0;
}
// Constructor that creates a named node.
public Node(String nodename){
name = nodename;
degree = 0;
}
// Getter for the name of a node.
public String getName() {
return name;
}
// Setter for the name of a node.
public void setName(String newName) {
name = newName;
}
// Getter for the degree of a node.
public int getDegree() {
return degree;
}
// Setter for the degree of a node.
public void setDegree(int newDegree) {
degree = newDegree;
}
// An easier-to-read string representation of a node's name.
@Override
public String toString(){
return "<"+name+">";
}
}