Effacer les filtres
Effacer les filtres

Remove node and reconnect edges in a very large graph

3 vues (au cours des 30 derniers jours)
IrisL
IrisL le 22 Juil 2022
Modifié(e) : IrisL le 22 Juil 2022
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.

Réponses (0)

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by