Find graph node names beginning with a few characters
조회 수: 1 (최근 30일)
이전 댓글 표시
Is there a way to find out all the node names of a graph that begins with a few characters?
For example, I am working with the CElegans digraph (wormwiring.org). It has nodes named 'DA01', 'DA02', etc. I want to know all the node names that begin with the characters 'DA'.
Thank you so much.
Kamal
댓글 수: 0
채택된 답변
Steven Lord
2021년 10월 7일
Using a modified version of one of the documentation examples and splitting the code into multiple lines for ease of explanation.
A = triu(magic(4));
names = {'alpha' 'beta' 'gamma' 'alphabet'};
G = graph(A,names,'upper','omitselfloops')
listOfNames = G.Nodes.Name
whichNodesStartWithA = startsWith(listOfNames, 'a')
namesStartingWithA = listOfNames(whichNodesStartWithA)
whichNodesAreTheyInG = findnode(G, namesStartingWithA)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!