フィルターのクリア

Remove node and reconnect edges in a very large graph

3 ビュー (過去 30 日間)
IrisL
IrisL 2022 年 7 月 22 日
編集済み: IrisL 2022 年 7 月 22 日
I asked a similar question before and tried to apply the code towards a large network with 6119 nodes and 7260 edges. The large network makes the code very inefficient.
The original question is: I have some nodes in an undirected graph that acts as a sort of 'temporary connector' node. I'd like to remove these nodes and update the edges in the graph so that all of the neighbors ponit to the next neighbors. Example: I have a graph 1 - 2 - 3. I'd like to remove node 2 and end up with the graph 1 - 3.
My end goal is to get an adjacency matrix of the graph after these 'temporary connector' node are removed. I want to know, whether the remaining nodes are incident to each other or not.
I am trying to figure out another way to conduct the work so that the computation can be quicker. Right now, I was able to remove 2000 nodes after running the code for 30+ hours. And the time for reming each node takes longer and longer. I think the problem being the number of neighbors explores when I remove nodes and reconnect edges.
My code is:
G1 = G;
for n = 1:length(node_need_to_be_remove)
neig = neighbors(G1,n);
for i=1:length(neig)
for j=i+1:length(neig)
G1=addedge(G1, neig(i), neig(j));
end
end
G1 = rmnode(G1,string(exclusion(n))); % remove the node also remover the edges to the node
%%%% Remove duplicated edges
G1 = simplify(G1);
end
I know this question may be too specific, but I appreciate any suggestions. Thanks.

回答 (0 件)

カテゴリ

Help Center および File ExchangeDirected Graphs についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by