Hi, I understand you want to segment your graphs in a particular way. Firstly, I would suggest you give a name to each of your nodes and not rely on the integer names, as the subgraph function which is part of the solution resets numerical node ids but will preserve named ids. I have added this modification in the code below, which takes the same graph object you mentioned in your question and does this operation. I have also plotted the graphs so you can see that it is as expected
s = [1 2 3 4 4 5 6 7 8];
t = [2 4 5 5 10 8 9 8 9];
w = [67 54 67 268 1 38 45 134 54];
n = {'n1','n2','n3','n4','n5','n6','n7','n8','n9','n10'}; % naming the nodes
G = graph(s,t,w,n);
n4 = neighbors(G,4);
H = rmedge(G,[4,4,4],n4); % split into 3 graphs
s1 = dfsearch(H,n4(1)); % find all components of the subgraphs starting at neighbours of 4
s2 = dfsearch(H,n4(2));
s3 = dfsearch(H,n4(3));
subgraph1 = subgraph(G,[4 ;s1]); % including 4 in the subgraphs
subgraph2 = subgraph(G,[4; s2]);
subgraph3 = subgraph(G,[4; s3]);
subplot(2,2,1);
plot(G,'EdgeLabel',G.Edges.Weight)
subplot(2,2,2);
plot(subgraph1,'EdgeLabel',subgraph1.Edges.Weight)
subplot(2,2,3);
plot(subgraph2,'EdgeLabel',subgraph2.Edges.Weight)
subplot(2,2,4);
plot(subgraph3,'EdgeLabel',subgraph3.Edges.Weight)
Links to function docs: