Student Support Forum: 'Find two adjacent nodes og a graph' topicStudent Support Forum > General > "Find two adjacent nodes og a graph"

 < Previous Comment | Next Comment > Help | Reply To Comment | Reply To Topic
 Author Comment/Response Bill Simpson 09/18/12 8:54pm Make an example graph In[4]:= g1=CompleteGraph[5];ShowGraph[g1] Extract all the edges In[7]:= e=ToUnorderedPairs[g1] Out[7]= {{1,2},{1,3},{1,4},{1,5},{2,3},{2,4},{2,5},{3,4},{3,5},{4,5}} Extract edges that include vertex 3 In[8]:= Cases[e,{___,3,___}] Out[8]= {{1,3},{2,3},{3,4},{3,5}} Extract the verticies adjacent to vertex 3 In[9]:= DeleteCases[Flatten[ae],3] Out[9]= {1,2,4,5} Thus verticies 1,2,4,5 are adjacent to vertex 3 URL: ,

 Subject (listing for 'Find two adjacent nodes og a graph') Author Date Posted Find two adjacent nodes og a graph Marco 09/17/12 5:26pm Re: Find two adjacent nodes og a graph Bill Simpson 09/18/12 8:54pm Re: Find two adjacent nodes og a graph Peter Pein 09/19/12 2:12pm
 < Previous Comment | Next Comment > Help | Reply To Comment | Reply To Topic