Define a class Digraph containing lists of vertices and edges and a class AdjacencyMatrix where a 1 indicates an edge between subscript vertices. Include constructors for automatic conversion.
What will be an ideal response?
```
onst int MAX_VERTICES = 6;
const int MAX_EDGES = MAX_VERTICES * MAX_VERTICES;
class Digraph;
class AdjacencyMatrix { // Represents a varying-size matrix that
// can be input from a file
public:
AdjacencyMatrix() {}
AdjacencyMatrix( const Digraph& ); // Constructor that initializes a
// matrix from a digraph
int getN() const; // Accessors
int getValue(int, int) const;
private:
int n;
int mat[MAX_VERTICES][MAX_VERTICES];
friend ostream& operator<< ( ostream&, const AdjacencyMatrix& );
friend istream& operator>> ( istream&, AdjacencyMatrix& );
};
class Digraph { // Represents a list of n vertices and varying number
// of edges connecting those vertices
public:
Digraph() {}
Digraph( const AdjacencyMatrix& ); // Constructor that initializes a
// digraph from an adjacency matrix
int getN() const; // Accessors
int getNumEdges() const;
void getEdge(const int, int&, int&) const;
private:
int n; // n vertices
int numEdges; // number of edges
int edges[MAX_EDGES][2]; // vertex pairs
friend ostream& operator<< ( ostream&, const Digraph& );
friend istream& operator>> ( istream&, Digraph& );
};
int main()
{
AdjacencyMatrix m1,m2;
Digraph d1,d2;
string infilename1, infilename2;
cout << endl << "Enter the Adjacency Matrix input file name => ";
cin >> infilename1;
ifstream infile1(infilename1.c_str(), ios::in);
cout << endl << "Enter the Digraph input file name => ";
cin >> infilename2;
ifstream infile2(infilename2.c_str(), ios::in);
infile1 >> m1;
infile2 >> d1;
m2 = AdjacencyMatrix(d1);
d2 = Digraph(m1);
cout << endl << "Adjacency Matrix entered:" << endl << m1;
cout << endl << "Digraph computed:" << endl << d2;
cout << endl << "Digraph entered:" << endl << d1;
cout << endl << "Adjacency Matrix computed:" << endl << m2;
cout << endl;
return 0;
}
```
You might also like to view...
Collectively, programs such as viruses, spyware, and worms are known as
a. malware. b. nuisance software. c. invasive software. d. intruders.
ESD is the acronym for ____________________discharge.
Fill in the blank(s) with the appropriate word(s).
Answer the following statement(s) true (T) or false (F)
1. The options bar associated with each of the marquee tools contains two menu buttons and settings to draw effective marquees. 2. Once a selection is made, you can add anti-aliasing like the kind shown in the bottom-right of the accompanying figure. 3. When drawing a marquee, if you want to start over, you can click somewhere else in the document window to deselect the marquee. 4. The arrow keys are never used to nudge a selection in small increments. 5. While duplicating, the mouse pointer changes to a black arrowhead with a white arrowhead behind it.
A classroom utilizes workstations running virtualization software for a maximum of one virtual machine per working station. The network settings on the virtual machines are set to bridged. Which of the following describes how the switch in the classroom should be configured to allow for the virtual machines and host workstation to connect to network resources?
A. The maximum-mac settings of the ports should be set to zero B. The maximum-mac settings of the ports should be set to one C. The maximum-mac settings of the ports should be set to two D. The maximum mac settings of the ports should be set to three