Difference between revisions of "CSC212 Lab 13 2014"

From dftwiki3
Jump to: navigation, search
(Problem #1)
(Problem #1)
Line 7: Line 7:
 
* Create a new program called '''Graph1.java''' and copy the code from this [[CSC212 Graph1.java | page]].
 
* Create a new program called '''Graph1.java''' and copy the code from this [[CSC212 Graph1.java | page]].
 
* Implement the DFS function, with the main function calling a recursive helper function.   
 
* Implement the DFS function, with the main function calling a recursive helper function.   
 +
<br />
 
; Question 1
 
; Question 1
 
: Make your new DFS start with a vertex of your choice, and display all the vertices it visits.  Below is an example of the output for <tt>G.DFS( 0 )</tt>.
 
: Make your new DFS start with a vertex of your choice, and display all the vertices it visits.  Below is an example of the output for <tt>G.DFS( 0 )</tt>.

Revision as of 19:59, 17 November 2014

--D. Thiebaut (talk) 11:19, 17 November 2014 (EST)



Problem #1


  • Create a new program called Graph1.java and copy the code from this page.
  • Implement the DFS function, with the main function calling a recursive helper function.


Question 1
Make your new DFS start with a vertex of your choice, and display all the vertices it visits. Below is an example of the output for G.DFS( 0 ).


DFS starting on 0: 0, 1, 2, 4, 3, 7, 8, 5, 6,


Question 2
Same question, but this time make DFS print the edges of the graph it visits. Below is an example of the output for G.DFS(0).


DFS starting on 0:
visiting Edge (0)---(1)
visiting Edge (1)---(2)
visiting Edge (1)---(4)
visiting Edge (4)---(3)
visiting Edge (3)---(7)
visiting Edge (7)---(8)
visiting Edge (1)---(5)
visiting Edge (5)---(6)


Problem #2


7-degrees of separation

Problem #3


All-Pairs Shortest Paths