1

For this project I'm creating several network graphs, but the scaling is off. The first network graph includes all of the nodes/categories and is rather large. The other network graphs are subsets of the full one. I'm using the same coordinates for each subset as the full graph in order to maintain the structure. The problem is that whenever I create a subset network, the scaling is completely off, despite having manually set the coordinates.

The full network looks like this: enter image description here

nodes<- read_csv("node_coords.csv")
viz_all <- visNetwork(sort(gvis$nodes),gvis$edges,main="All Connections",width = "100%",height = "850px") %>%
  visLayout(randomSeed = 123) %>%
  visEdges(smooth =T,
           arrows =list(to = list(enabled = TRUE, scaleFactor = .5)),
           color = list(highlight = "black"))  %>% #https://datastorm-open.github.io/visNetwork/edges.html
  visPhysics(stabilization = FALSE)  %>%
  visIgraphLayout(smooth=FALSE,physics=FALSE, layout="layout_with_fr", layoutMatrix = gcoords) %>%
  visLayout(randomSeed=123,improvedLayout = TRUE)%>%
  visInteraction(navigationButtons = TRUE)%>%
  visOptions(selectedBy = list(variable = c("program"), multiple = TRUE),
             highlightNearest = list(enabled = T, hover = T),
             nodesIdSelection = TRUE)%>%
  addFontAwesome() %>%
  visLegend(position = "left",addNodes = lnodes, useGroups = FALSE,stepY=100)

viz_all$x$nodes <- viz_all$x$nodes %>% left_join(nodes, by = 'id') %>% select(-c('x.x', 'y.x')) %>% rename(x = x.y, y=y.y)

viz_all

And an example of a subset is this: enter image description here

viz_ag <- visNetwork(sort(gvis_agriculture$nodes),gvis_agriculture$edges, main="Agriculture Subset",width = "100%",height = "850px") %>%
  visLayout(randomSeed = 123) %>%
  visEdges(smooth =T,
           arrows =list(to = list(enabled = TRUE, scaleFactor = .5)),
           color = list(color = "lightblue", highlight = "black"))  %>% #https://datastorm-open.github.io/visNetwork/edges.html
  visPhysics(stabilization = FALSE)  %>%
  visIgraphLayout(smooth=FALSE,physics=FALSE, layout="layout_with_fr") %>%
  visLayout(randomSeed = 123,improvedLayout = TRUE)%>%
  visInteraction(navigationButtons = TRUE)%>%
  visOptions(selectedBy = list(variable = c("program"), multiple = TRUE),
             highlightNearest = list(enabled = T, hover = T),
             nodesIdSelection = TRUE)%>%
  addFontAwesome() %>%
  visLegend(position = "left", useGroups = FALSE,stepY=100)

viz_ag$x$nodes <- viz_ag$x$nodes %>% left_join(nodes, by = 'id') %>% select(-c('x.x', 'y.x')) %>% rename(x = x.y, y=y.y)

viz_ag

Is there anyway to maintain the structure of the first network graph in the subsets? Or maybe I'm attacking this all wrong?

ethan tenison
  • 393
  • 3
  • 14

1 Answers1

1

Not sure if this will help, because it's just a hunch. But from my understanding of graph networks, the size of the node is usually related to it's importance. More connections/edges = bigger size (relative to the other nodes). I suspect that in the reduced model, the relative importance of some nodes will change dramatically due to certain other nodes and edges being omitted. I think your issue is more to do with node size than the coordinates you are setting (perhaps).

thehand0
  • 1,123
  • 4
  • 14