small question

I am looking for a specific value in “from_node” edge struct, how do I find it…I need to traverse all edges of adjList, How do I access that?
Thank you!

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
  //this is just a draft 
Struct Edge

{

Int from_node;

Int to_node;

Int weight;

String name;

}

 

In main ()

Egde e;

Vector <list<Edge> > adjList;

 

// I am looking for a specific value in “from_node” edge struct, 
//how do I find it…I need to traverse all edges of adjList, How do I access that?

For (int i=0; i< adjList.size(); i++)

{

???

}



Last edited on
Each adjList[i] is of type list<Edge>, so you have to iterate over them. adjList[i][j] would be of type Edge, which has member from_node.
Topic archived. No new replies allowed.