Search code examples
rnetworkxgephipgrouting

Remove a node from a network without affecting the interaction of others nodes


This is a sample of my big graph:

enter image description here

And i want to remove the node "B" without affecting the interaction of other nodes:

enter image description here

I worked it with "R", "PgRouting","gephi" and "networkx". And I dont found an efficient way to do it. Any suggestion?


Solution

  • Using R and the igraph package:

    library(igraph)
    g <- make_graph(~ B -- A:C:D, A-E, C-F, D-G)
    plot(g)
    

    enter image description here

    node <- "B"
    g_2 <- 
      g %>% 
      union(connect(make_ego_graph(g, 1, node)[[1]], 2)) %>% 
      delete_vertices(node)
    plot(g_2)
    

    enter image description here