Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tanmim Hanifa
GameAICW2
Commits
43fd38f1
Commit
43fd38f1
authored
Oct 31, 2017
by
Tanmim Hanifa
Browse files
adding script file
parents
Changes
1
Hide whitespace changes
Inline
Side-by-side
YellowGraph.cs
0 → 100644
View file @
43fd38f1
using
System
;
using
System.Collections.Generic
;
class
YellowGraph
:
Graph
{
// List of nodes in this graph
private
List
<
Node
>
nodes
;
// An adjacency matrix, recording edges between nodes
// Edge FROM node i to node j is recorded in adjMatrix[i,j]
// Each int entry records the edge cost (> -1)
// If entry is 0 there is no edge
private
int
[,]
adjMatrix
;
public
YellowGraph
()
{
nodes
=
new
List
<
Node
>();
adjMatrix
=
new
int
[
0
,
0
];
}
// ADD MISSING METHODS HERE
public
void
Write
()
{
Console
.
WriteLine
(
"YellowGraph"
);
for
(
int
i
=
0
;
i
<
nodes
.
Count
;
i
++)
{
Console
.
Write
(
nodes
[
i
]
+
": "
);
bool
first
=
true
;
for
(
int
j
=
0
;
j
<
nodes
.
Count
;
j
++)
{
if
(
adjMatrix
[
i
,
j
]
>
0
)
{
if
(!
first
)
Console
.
Write
(
", "
);
Console
.
Write
(
nodes
[
j
]
+
"("
+
adjMatrix
[
i
,
j
]
+
")"
);
first
=
false
;
}
}
Console
.
Write
(
"\n"
);
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment