Design and implementation of ERGODIC algorithm for experiment four graph

Source: Internet
Author: User

Experiment Name: Design and implementation of graph traversal algorithm

Second, the purpose of the experiment:

1. Grasp the algorithm of depth-first traversal of graphs.

2. Grasp the breadth-first traversal algorithm of graphs.

3. Experiment Chapter: Algorithm design and analysis fourth chapter

Third, the experimental content. Experimental problems and program running results

The first part breadth-first traversal algorithm

1. Analyze graph class and draw graph object data structure after initialization of graph class.

2. Analyze the BFS function and draw a flowchart.

3. The above procedure int data[7][7]={{1,-1,-1,-1,-1,-1,-1},

{6, 3, 2,-1,-1,-1,-1},

{0,-1,-1,-1,-1,-1,-1},

{2, 0,-1,-1,-1,-1,-1},

{6, 5,-1,-1,-1,-1,-1},

{1,-1,-1,-1,-1,-1,-1},

{5, 3,-1,-1,-1,-1,-1}};

is the input to the textbook figure 4-1, and the order of breadth precedence starting from 0 is:

4. If the traversal starts at node 4, what is the order of breadth precedence?

5. Analyze when the graph class object, at the time of input at 1, the breadth precedence starting from 0. Design data[][] Data for input, and gives the sequence of traversal in the case of this type of input.

6. Rewrite the program, output the parent array value, and draw the breadth-first deep forest of Figure 1 according to the parent.

The second part depth-first traversal algorithm

    1. Analyze the DFS program and give the DFS flowchart:
    2. The DFS traversal order for Figure 4-1 is:
    3. When the DFS traversal of Figure 1, what is the traversal order, based on the parent value, infer what depth-first deep forest is.
    4. Design a diagram yourself and calculate the depth traversal and breadth traversal sequence through the program.

Iv. Summary of the experiment and experience:

Design and implementation of ERGODIC algorithm for experiment four graph

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.