Adjacency Matrix is a 2D array of size V x V where V is the number of vertices in a graph.
Let the 2D array slot adj[i][j] = 1 indicates that there is an edge from vertex i to vertex j.
Adjacency matrix for undirected graph is always symmetric. Adjacency Matrix is also used to represent weighted graphs. If adj[i][j] = w, then there is an edge from vertex i to vertex j with weight w.
Python code is as:
========================================
V = ['A', 'B', 'C', 'D']
E = [('A', 'B', 12), ('B', 'C', 12), ('C', 'D',11), ('D', 'A', 3), ('B', 'D', 10), ('A', 'C', 9)]
pos = {'A':[1,1], 'B':[3, 1], 'C':[3, 3], 'D':[1,3]}
#Directed Graph
G = nx.DiGraph()
G.add_nodes_from(V)
G.add_weighted_edges_from(E)
G.nodes
G.edges
weight = nx.get_edge_attributes(G, 'weight')
nx.draw_networkx(G, with_labels=True, pos=pos, node_size= 1500, node_color='r', edge_color='g', arrowsize=33, font_size=16)
nx.draw_networkx_edge_labels(G, pos, edge_labels=weight, font_size=16)
nx.to_pandas_edgelist(G)
nx.to_pandas_adjacency(G)