# Convert between graph representations. [tag:code-golf][tag:graph-theory][tag:matrix] ## What? Let's say I have this graph: ``` 1 \ \ 2 3 \ / \ / 4 ``` I can represent it in 2 ways: - 1. A list of connected vertices. `[[1,3],[2,4],[3,4]]` - 2. A boolean matrix which shows where edges are: ``` c |1 2 3 4 --|------- 1 |0 0 1 0 2 |0 0 0 1 3 |1 0 0 1 4 |0 1 1 0 ----- or ----- [[0,0,1,0],[0,0,0,1],[1,0,0,1],[0,1,1,0]] ``` You code should take input in the form of 1 and output it as 2. The graph is not directed (aka undirected graph). You can also accept input which is 0-indexed. ## Test cases ``` [[1,2],[3,4]] -> [[0,1,0,0],[1,0,0,0],[0,0,0,1],[0,0,1,0]] [[1,3],[2,4],[3,4]] -> [[0,0,1,0],[0,0,0,1],[1,0,0,1],[0,1,1,0]] ```