Project(forChapter13)CS56.pdf

Project(forChapter13)CS56.pdf - Project Display a Graph...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Project: Display a Graph Problem Description: A graph consists of vertices and edges that connect vertices. Write a program that reads a graph from a file and displays it on a panel. The first line in the file contains a number that indicates the number of vertices (n). The vertices are labeled as 0, 1, ..., n-1. Each subsequent line, with the format u x y v1, v2, ..., describes that the vertex u is located at position (x, y) with edges (u, v1), (u, v2), etc. Figure (a) gives an example of the file for a graph. Your program prompts the user to enter the name of the file, reads data from the file, and displays the graph on a panel, as shown in Figure (b). File 6 0 30 30 1 2 1 90 30 0 3 2 30 90 0 3 4 3 90 90 1 2 4 5 4 30 150 2 3 5 5 90 150 3 4 0 2 3 1 4 5 (a) (b) The program reads the information about the graph and displays it visually. Analysis: A graph is a mathematical structure with vertices and edges that connect the vertices. A graph is a very useful tool for modeling real-world problems. This project is to display the graph. The information for
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern