FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java/node.java at master · javaarchive/Java · GitHub
This repository was archived by the owner on Feb 29, 2024. It is now read-only.
javaarchive
/
Java
Public archive
Notifications
You must be signed in to change notification settings
Fork
0
Star
2
Code
Issues
0
Pull requests
3
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
Java
/
node.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
97 lines (95 loc) · 2.03 KB
Breadcrumbs
Java
/
node.java
Copy path
File metadata and controls
97 lines (95 loc) · 2.03 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import
java
.
util
.*;
public
class
node
{
private
int
id
= -
1
;
private
static
int
nextId
=
101
;
public
void
init
() {
this
.
id
=
nextId
;
nextId
++;
}
ArrayList
<
node
>
connectedNodes
;
public
node
() {
init
();
this
.
connectedNodes
=
new
ArrayList
<
node
>(
0
);
}
public
node
(
node
n
) {
init
();
this
.
connectedNodes
=
new
ArrayList
<
node
>(
1
);
this
.
connectedNodes
.
add
(
n
);
}
public
void
connect
(
node
n
) {
this
.
connectedNodes
.
add
(
n
);
}
public
ArrayList
<
node
>
getChildNodes
(){
return
this
.
connectedNodes
;
}
public
int
graphId
;
public
void
setId
(
int
id
) {
this
.
graphId
=
id
;
}
public
node
setid
(
int
id
) {
this
.
graphId
=
id
;
return
this
;
}
public
int
getId
() {
return
this
.
graphId
;
}
public
int
getUniqueId
() {
return
this
.
id
;
}
/* Diff mode settings
* 0 - compare by id
* 1 - compare by unique id
* 2 - Compare by connected nodes
*/
public
static
int
diffmode
=
0
;
@
Override
public
boolean
equals
(
Object
obj
) {
if
(
obj
instanceof
node
) {
node
e
= (
node
)
obj
;
if
(
diffmode
==
0
) {
return
(
this
.
getId
() ==
e
.
getId
());
}
else
if
(
diffmode
==
1
) {
return
(
this
.
getUniqueId
() ==
e
.
getUniqueId
());
}
else
if
(
diffmode
==
2
) {
return
(
this
.
connectedNodes
.
equals
(
e
.
connectedNodes
));
}
}
else
{
return
false
;
}
return
false
;
}
public
void
linkNode
(
node
n
) {
this
.
connectedNodes
.
add
(
n
);
}
public
node
addChild
(
node
n
) {
this
.
linkNode
(
n
);
return
this
;
}
@
Override
public
String
toString
() {
StringBuilder
sb
=
new
StringBuilder
(
"node("
);
sb
.
append
(
"id = "
);
sb
.
append
(
this
.
graphId
);
sb
.
append
(
", uniqueId = "
);
sb
.
append
(
this
.
getUniqueId
());
sb
.
append
(
", children = "
);
sb
.
append
(
this
.
connectedNodes
.
toString
());
sb
.
append
(
" )"
);
return
sb
.
toString
();
}
private
boolean
visited
;
public
void
reset
() {
this
.
visited
=
false
;
}
public
void
visit
() {
this
.
visited
=
true
;
}
public
boolean
isvisited
() {
return
this
.
visited
;
}
public
static
void
main
(
String
[]
args
) {
// TODO Auto-generated method stub
node
.
diffmode
=
0
;
System
.
out
.
println
((
new
node
()).
addChild
(
new
node
()));
}
}
Back
|
FazBrowse Home
|
New Git URL