There are three kinds of actuaries: those who can count, and those who can't.
Not really consistent. Uses different braces placing style (i.e.: Line 33, Line 37). But in general way better than what we see usually.Carey Brown wrote:Your indentation is good and consistent.
s ravi chandran wrote:Thanks for all the replies.
s ravi chandran wrote:(...)
If I use queue, how should it work?
1. Take an element , mark it visited.
2. Find it's neighbors, move to each neighbor and mark it visited.
3. Go to Step 1.
Will this logic work?
There are three kinds of actuaries: those who can count, and those who can't.
There are three kinds of actuaries: those who can count, and those who can't.
There are three kinds of actuaries: those who can count, and those who can't.
There are three kinds of actuaries: those who can count, and those who can't.
There are three kinds of actuaries: those who can count, and those who can't.
s ravi chandran wrote:Does the adjacency list functionality look correct?
There are three kinds of actuaries: those who can count, and those who can't.
There are three kinds of actuaries: those who can count, and those who can't.
There are three kinds of actuaries: those who can count, and those who can't.
There are three kinds of actuaries: those who can count, and those who can't.
s ravi chandran wrote:
Here are the items that are pending:
1) Complete AdjacencyMatrix and figure out how to use it in this program.
2) Utilizing listOfVertices in the program.
There are three kinds of actuaries: those who can count, and those who can't.
There are three kinds of actuaries: those who can count, and those who can't.
There are three kinds of actuaries: those who can count, and those who can't.
Next it shows that 0-->1 is connected, okay. But then it shows that 1-->0 is connected as well. Although that is true, given the nested for-next loop that you issue I would have expected to see the line '0-->2 is connected' first.
Also interesting is that 3-->4 and 4-->3 areboth displayed. Why?
And finally, although we see that there are only 4 edges, your method nevertheless says there are 5. And since 5 > nrOfVertices - 1 (i.e. 4) it concludes that the graph is not connected.
Suppose we have 6 vertices, how many edges do we have? (and edge(0.1) == edge(1,0) so beware of double counting).
And coming back to the graph that I tested: we have 4 edges, with 5 vertices. Yet the graph is not connected.
It is clear: counting the edges does not tell us much about the graph being connected. That is why I asked you to create three different graphs and to inspect th adjacency matrices, to get an idea if these matrices could answer the connectedness question without further ado.
If you are using a rototiller, you are doing it wrong. Even on this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|