r""" Reading an Adjacency matrix Parameters: None Returns: tuple: A tuple containing a list of edges and number of edges Example: >>> # Simulate user input for 3 nodes >>> input_data = "4\n0 1 0 1\n1 0 1 0\n0 1 0 1\n1 0 1 0\n" >>> import sys,io >>>
()
| 217 | |
| 218 | |
| 219 | def adjm(): |
| 220 | r""" |
| 221 | Reading an Adjacency matrix |
| 222 | |
| 223 | Parameters: |
| 224 | None |
| 225 | |
| 226 | Returns: |
| 227 | tuple: A tuple containing a list of edges and number of edges |
| 228 | |
| 229 | Example: |
| 230 | >>> # Simulate user input for 3 nodes |
| 231 | >>> input_data = "4\n0 1 0 1\n1 0 1 0\n0 1 0 1\n1 0 1 0\n" |
| 232 | >>> import sys,io |
| 233 | >>> original_input = sys.stdin |
| 234 | >>> sys.stdin = io.StringIO(input_data) # Redirect stdin for testing |
| 235 | >>> adjm() |
| 236 | ([(0, 1, 0, 1), (1, 0, 1, 0), (0, 1, 0, 1), (1, 0, 1, 0)], 4) |
| 237 | >>> sys.stdin = original_input # Restore original stdin |
| 238 | """ |
| 239 | n = int(input().strip()) |
| 240 | a = [] |
| 241 | for _ in range(n): |
| 242 | a.append(tuple(map(int, input().strip().split()))) |
| 243 | return a, n |
| 244 | |
| 245 | |
| 246 | """ |