CS 259: Homework 5 - Creating a Labeled Directed Acyclic Graph (LDAG), Assignments of Computer Science

The requirements for homework 5 in cs 259, which involves creating an implementation for the class ldg, a labeled directed graph, and a derived class ldag, a labeled directed acyclic graph. Students are required to create header and source files for both classes, implement functions such as constructor, destructor, add_vertex, connect, remove_edge, and print_dlg for ldg, and an additional function total_order for ldag. The total_order function should return a linked list of the labels of the vertices in topological order using depth-first search.

Typology: Assignments

Pre 2010

Uploaded on 07/23/2009

koofers-user-a6p-1
koofers-user-a6p-1 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 259
Homework 5:
Assigned on Monday, October 18, 1999
Due on Friday, October 29, 1999
1. Use your header file from Homework 3 to create an
implementation for the class LDG. Recall that each LDG
object will be a “labeled directed graph.” A labeled
directed graph is a set of vertices (also called nodes) and
directed edges. For each pair of vertices (a,b), there may
be an edge going from a to b and also there may be an
edge going from b to a. Each vertex will have a label -- a
(unique) integer value that is associated with it. LDG will
have the following functions:
A) constructor LDG (also create a copy constructor)
B) destructor ~LDG
C) add_vertex: Adds a new vertex with label of type integer.
D) connect: places edge from one vertex to another
E) remove_edge: removes an edge
F) isomorphic: You don’t have to implement this.
G)print_DLG: outputs a list of graph edges to cout.
H) num_vertices: returns the number of vertices in the graph
2. Create .h and .cpp files for a derived class of LDG called
LDAG, “labeled directed acyclic graph.” A graph is
acyclic if, for each vertex, there is no sequence of
directed edges leading back to that vertex. This derived
class should have one additional function:
A) total_order: this function returns a linked-list of the
labels of the vertices of the graph. We say that “label a > label
b” if label b occurs after label a does in the linked list. The linked
list should have the property that, for all a and b, if there is a way
to reach b from a using directed edges, then label a > label b.
Use the depth-first search algorithm described in class.

Partial preview of the text

Download CS 259: Homework 5 - Creating a Labeled Directed Acyclic Graph (LDAG) and more Assignments Computer Science in PDF only on Docsity!

CS 259

Homework 5:

Assigned on Monday, October 18, 1999 Due on Friday, October 29, 1999

  1. Use your header file from Homework 3 to create an implementation for the class LDG. Recall that each LDG object will be a “labeled directed graph.” A labeled directed graph is a set of vertices (also called nodes) and directed edges. For each pair of vertices (a,b), there may be an edge going from a to b and also there may be an edge going from b to a. Each vertex will have a label -- a (unique) integer value that is associated with it. LDG will have the following functions: A) constructor LDG (also create a copy constructor) B) destructor ~LDG C) add_vertex: Adds a new vertex with label of type integer. D) connect: places edge from one vertex to another E) remove_edge: removes an edge F) isomorphic: You don’t have to implement this. G) print_DLG: outputs a list of graph edges to cout. H) num_vertices: returns the number of vertices in the graph
  2. Create .h and .cpp files for a derived class of LDG called LDAG , “labeled directed acyclic graph.” A graph is acyclic if, for each vertex, there is no sequence of directed edges leading back to that vertex. This derived class should have one additional function: A) total_order: this function returns a linked-list of the labels of the vertices of the graph. We say that “label a > label b” if label b occurs after label a does in the linked list. The linked list should have the property that, for all a and b, if there is a way to reach b from a using directed edges, then label a > label b. Use the depth-first search algorithm described in class.