GRADJACENTNODES Find list of nodes adjacent to a given node. NEIGHS = grAdjacentNodes(EDGES, NODE) EDGES: the complete edges list (containing indices of neighbor nodes) NODE: index of the node NEIGHS: the nodes adjacent to the given node. NODE can also be a vector of node indices, in this case the result is the set of neighbors of any input node, excluding the input nodes. Example % create a basic graph and display it nodes = [10 10;20 10;10 20;20 20;27 15]; edges = [1 2;1 3;2 4;2 5;3 4;4 5]; figure; drawGraph(nodes, edges); hold on; drawNodeLabels(nodes, 1:5) axis equal; axis([0 40 0 30]); % compute list of nodes adjacent to node with index 2 grAdjacentNodes(edges, 2) ans = 1 4 5 See Also grAdjacentEdges
Package: matgeom