So here is my code
void Graph::Print() const
{
cout << "Number of verticies in graph: " << size << endl;
cout << "-------- graph -------" << endl;
list<int>::iterator a;
for(int i=0;i<size;i++)
{
cout<<labels[i]<<":";
for(auto a=adj_list[i].begin();a!=adj_list[i].end();a++)
{
cout<< labels[*a] << ", ";
if(a!=adj_list[i].end())
}
cout<<endl;
}
cout << "------- end of graph ------" << endl;
}
I am trying to have output like this where the comma is only printed between the letters but not if there is a single letter.
-------- graph -------
A: B, C, E
B: A, D, F
C: A, G
D: B
E: A, F
F: B, E
G: C
------- end of graph ------
my current output is
-------- graph -------
A:B, C, E,
B:A, D, F,
C:A, G,
D:B,
E:A, F,
F:B, E,
G:C,
------- end of graph ------