Question: In Python i have the following adjacency matrix: np.array([[0,1,0,0,0,0,0,0,0,0,0], [1,0,1,0,0,0,0,0,0,0,0], [0,1,0,0,1,0,0,0,0,0,0], [0,0,0,0,1,1,0,1,0,0,0], [0,0,1,1,0,1,0,1,0,0,0], [0,0,0,1,1,0,1,1,0,0,0], [0,0,0,0,0,1,0,0,1,0,0], [0,0,0,1,1,1,0,0,0,0,0], [0,0,0,0,0,0,1,0,0,1,0], [0,0,0,0,0,0,0,0,1,1,0], [0,0,0,0,0,0,0,0,0,1,0]]) This is stored in a variable
In Python i have the following adjacency matrix:
np.array([[0,1,0,0,0,0,0,0,0,0,0], [1,0,1,0,0,0,0,0,0,0,0], [0,1,0,0,1,0,0,0,0,0,0], [0,0,0,0,1,1,0,1,0,0,0], [0,0,1,1,0,1,0,1,0,0,0], [0,0,0,1,1,0,1,1,0,0,0], [0,0,0,0,0,1,0,0,1,0,0], [0,0,0,1,1,1,0,0,0,0,0], [0,0,0,0,0,0,1,0,0,1,0], [0,0,0,0,0,0,0,0,1,1,0], [0,0,0,0,0,0,0,0,0,1,0]])
This is stored in a variable a. Then, I have 11 string names attached to the adjacency matrix, these are stored in variable b. Then, i have a variable c that are chosen from the list in variable b.
First I need a way to connect variable a to variable b.
Then I need a function d(a,b,c): that will return the number of connections a string has. So print(d(a,b,'string') should print a number. The language is in python. So the string linked to the first row should end up with the number 2. I need actual code in Python, no walk throughs.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
