the numbers in the box represent the vertices index represents vertex awith its adjacent nodes being and using list for the representation is quite restrictive because we lack the ability to directly use the vertex labels dictionary is therefore more suited to represent the graph in the diagramwe can use the following statementsgraph dict(graph[' '[' '' 'graph[' '[' ',' 'graph[' '[' '' '' ',' 'graph[' '[' '' 'graph[' '[' 'now we easy establish that vertex has the adjacent vertices and vertex has vertex as its only neighbor adjacency matrix another approach by which graph can be represented is by using an adjacency matrix matrix is two-dimensional array the idea here is to represent the cells with or depending on whether two vertices are connected by an edge given an adjacency listit should be possible to create an adjacency matrix sorted list of keys of graph is requiredmatrix_elements sorted(graph keys()cols rows len(matrix_elementsthe length of the keys is used to provide the dimensions of the matrix which are stored in cols and rows these values in cols and rows are equaladjacency_matrix [[ for in range(rows)for in range(cols)edges_list [we then set up cols by rows arrayfilling it with zeros the edges_list variable will store the tuples that form the edges of in the graph for examplean edge between node and will be stored as (abthe multidimensional array is filled using nested for loopfor key in matrix_elementsfor neighbor in graph[key]edges_list append((key,neighbor)