problem in neighbors function

3 visualizaciones (últimos 30 días)
huda nawaf
huda nawaf el 27 de Jul. de 2022
Editada: huda nawaf el 2 de Ag. de 2022
hello,
This is my graph
G=[0 1 1 0 0 0;1 0 1 1 0 0; 1 0 0 1 1 0; 0 0 0 0 1 0; 0 0 0 0 0 1; 0 1 0 1 1 0];
when I apply the function neighbors
neighbors(G,active_nodes_last_round(individual));
where active_nodes_last_round(individual)=1;
I got the following error:
Undefined function 'neighbors' for input arguments of
type 'double'.
Error in IC_paper1 (line 26)
potential_infected=neighbors(G_duplicate,active_nodes_last_round(individual));
Thanks in advance

Respuestas (1)

Steven Lord
Steven Lord el 27 de Jul. de 2022
The neighbors function, in this context, requires its first input to be a graph object not an adjacency matrix. Create a graph object from your adjacency matrix by calling graph and pass the resulting object into neighbors.
  13 comentarios
huda nawaf
huda nawaf el 2 de Ag. de 2022
Editada: huda nawaf el 2 de Ag. de 2022
thanks @ steven
I installed trail ver. , and I run the code.
I created adjacancy mat. and call graph, then run code without any problem.
In fact the code is existing in a paper, it is working but the results are not satisfied.

Iniciar sesión para comentar.

Categorías

Más información sobre Networks en Help Center y File Exchange.

Productos


Versión

R2013a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by