2014-05-12

CS 146 Final Practice #8 Section 5.

Originally Posted By: aontiveros
Suppose we had a graph G and we wanted to determine the number of nodes in a connected component involving a vertex v. Suggest some algorithms we learned in class which could be used to solve this problem.

Our suggestions are:
Breadth First Search
We use Breadth First search as this algorithm searches systematically through all edges of G to discover every vertex that is reachable through the graph G. Using this we can count each new node the algorithm explores until the search is finished.

Topological Sort. (Depth-first search)
Depth-first search explores edges out of the most recently discovered vertex v that still has unexplored edges leaving it Once all of v's edges have been explored, the each "backtracks" to explore edges leaving the vertex from which v was discovered. This process continues until we have discovered all the vertices that are reachable from the original source vertex. This allows us to count all nodes in the graph.



Prim's Algorithm
With Prim's algorithm, it has the property that the edges in the set will always form a single tree. This tree created starts from the our arbitrary root and grows until the tree spans all the vertices in graph G. Using this property we can count the number of nodes by traversing through the created tree to get the number of nodes in the graph.

The students that did this problem are:
Antonio Ontiveros
Mark Santiago
Morgan Chang
Chris Leung
'''Originally Posted By: aontiveros''' Suppose we had a graph G and we wanted to determine the number of nodes in a connected component involving a vertex v. Suggest some algorithms we learned in class which could be used to solve this problem.<br><br>Our suggestions are:<br>Breadth First Search<br> We use Breadth First search as this algorithm searches systematically through all edges of G to discover every vertex that is reachable through the graph G. Using this we can count each new node the algorithm explores until the search is finished.<br><br>Topological Sort. (Depth-first search)<br> Depth-first search explores edges out of the most recently discovered vertex v that still has unexplored edges leaving it Once all of v's edges have been explored, the each &quot;backtracks&quot; to explore edges leaving the vertex from which v was discovered. This process continues until we have discovered all the vertices that are reachable from the original source vertex. This allows us to count all nodes in the graph.<br><br><br> <br>Prim's Algorithm<br> With Prim's algorithm, it has the property that the edges in the set will always form a single tree. This tree created starts from the our arbitrary root and grows until the tree spans all the vertices in graph G. Using this property we can count the number of nodes by traversing through the created tree to get the number of nodes in the graph.<br><br>The students that did this problem are:<br>Antonio Ontiveros<br>Mark Santiago<br>Morgan Chang <br>Chris Leung
X