Problem D
Graph Representations
Below are three graphs taken from your Textbook. Output their representation using the format specified below. Your solution may use an algorithm or a Hard-Coded answer.
![\includegraphics[width=.4\textwidth ]{g1}](/problems/ryerson.graphreps/file/statement/en/img-0001.png)
![\includegraphics[width=.4\textwidth ]{g2}](/problems/ryerson.graphreps/file/statement/en/img-0002.png)
![\includegraphics[width=.4\textwidth ]{g3}](/problems/ryerson.graphreps/file/statement/en/img-0003.png)
Input
Input will consist of a single line of input that will say either "Graph 1", "Graph 2", or "Graph 3";
Output
Your output should be the Adjecency matrix representation of the specified graph followed by an empty line. Then, print the Adjecency List representation of the specified graph.
The matrix format for a graph with $N$ vertices consists of $N+1$ lines. The first line contains an asterisk followed by the names of all $N$ vertices separated by spaces. Every line afterward consists of a vertex name, followed by $N$ instances of 0s or 1s that indicate whether the vertices represented by this row and column are connected.
The Adjecency List format consists of $N$ lines where each line starts with a vertex name. After the name follows a vertical bar and then the names of all connected vertices separated by spaces.
Sample Input 1 | Sample Output 1 |
---|---|
Graph 1 |
* a b c d e f a 0 0 1 1 0 0 b 0 0 1 0 0 1 c 1 1 0 0 1 0 d 1 0 0 0 1 0 e 0 0 1 1 0 1 f 0 1 0 0 1 0 a | c d b | c f c | a b e d | a e e | c d f f | b e |