0

Given an adjacency matrix, How to draw a graph with matplotlib?

I referred to this but I am getting an error

AttributeError: 'list' object has no attribute 'shape'

I have a 2d list with same number of rows and column

class Graph:
def __init__(self,Vertices):
    self.V=Vertices
    self.graph=[]
    self.path=[]
    for i in range(self.V):
        l=[]
        for j in range(self.V):
            l.append(0)
        self.graph.append(l)

This is what I am doing and for drawing I used the link mentioned above.

Am I missing something or what should I do ?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
The Law
  • 11
  • 3
  • If you are free to use any library, I recommend you to take a look at [`networkx`](https://networkx.org/documentation/stable/tutorial.html), which you already linked accidentally – Sparky05 Feb 26 '21 at 09:01
  • @Sparky05 i am using networkx the link i mentioned above has an answer code anywho I was able to debug it thanks – The Law Feb 27 '21 at 10:25

0 Answers0