MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / main

Function main

CPP/graph_tree/bfs.cpp:41–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41int main()
42{
43 cout<<"Enter Node_";
44 cin>>n;
45 cout<<"Enter Edges_";
46 cin>>m;
47 int x,y;
48 for(int i=1;i<=m;i++)
49 {
50 cin>>x;
51 cin>>y;
52 adjList[x].push_back(y);
53 }
54
55 for(int i=1;i<=n;i++)
56 {
57 cout<<i<<" -->";
58 for(int j=0;j<adjList[i].size();j++)
59 {
60 cout<<adjList[i][j]<<" ";
61 }
62 cout<<endl;
63 }
64
65bfs(1);
66for(int i=1;i<=n;i++)
67{
68 cout<<"\tVertex="<<i;
69 cout<<"\tParent="<<parent[i];
70 cout<<"\tDistance="<<dist[i];
71 cout<<endl;
72}
73 return 0;
74}

Callers

nothing calls this directly

Calls 3

push_backMethod · 0.80
bfsFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected