How to find all the edges connecting a specific node with other nodes?
20 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Rayan Glus
am 20 Mai 2021
Kommentiert: Rayan Glus
am 21 Mai 2021
Hi,
Let G be an undirected graph of 1000 nodes. How can I find all the edges of a specific node?
I cannot pass the node's ID as an input argument to the built-in function "findedge", so I would appreciate your help and ideas.
Thanks
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (1)
Steven Lord
am 20 Mai 2021
Let's take a sample undirected graph.
G = graph(bucky);
What nodes are connected to node 51?
N = neighbors(G, 51)
Let's plot the graph then highlight node 51 and its neighbors in the plot with large red stars instead of the small blue circles of the rest of the nodes.
h = plot(G);
highlight(h, [51; N], 'MarkerSize', 12, 'NodeColor', 'r', 'Marker', '*')
We can see that each of nodes 49, 52, and 55 are indeed connected to node 51.
Siehe auch
Kategorien
Mehr zu Graph and Network Algorithms finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!