I have aList< List< int> > graph;
I have used it for representing an undirected graph.
When i add a new edge graph[u].Add[v];
, I am unable to itertate for a specific graph[u]
.
Asked
Active
Viewed 327 times
0
![](../../users/profiles/4042239.webp)
js-ninja
- 3
- 1
-
1You will need to post your actual code, nobody can help you on this little information. – nvoigt Mar 09 '15 at 07:24
-
@nvoigt isnt that my actual code huh? – js-ninja Nov 22 '16 at 11:04
1 Answers
1
Since your graph is undirected, you probably want to indicate both that u is connected to v and that v is connected to u.
graph[u].Add(v);
graph[v].Add(u);
Then you can see the nodes connected to u by iterating graph[u].
![](../../users/profiles/4648708.webp)
Matthew Hyndman
- 51
- 2