I have tried to find the center node in an Actor-Actor network. When I said center node, I meant that the node which has the shortest paths to all other nodes in network.
For example:
df <- structure(list(Movie.Name = structure(c(1L, 1L, 1L, 1L, 2L, 2L,
2L, 2L, 2L, 3L, 3L, 3L, 4L, 4L, 4L), .Label = c("A", "B", "C",
"D"), class = "factor"), Actor.Name = structure(c(1L, 5L, 6L,
7L, 8L, 5L, 9L, 1L, 10L, 11L, 8L, 12L, 2L, 3L, 4L), .Label = c("Actor1",
"Actor10", "Actor11", "Actor12", "Actor2", "Actor3", "Actor4",
"Actor5", "Actor6", "Actor7", "Actor8", "Actor9"), class = "factor")), .Names = c("Movie.Name",
"Actor.Name"), class = "data.frame", row.names = c(NA, -15L))
From this bipartite network, I projected the actor-actor network and find shortest path for all nodes with this code:
library(igraph)
g_graph <- graph.data.frame(df,directed=FALSE)
V(g_graph)$type <- bipartite_mapping(g_graph)$type
# project only actor&actor network
projected_g <- bipartite_projection(g_graph, multiplicity = TRUE, which = TRUE)
# Get connected nodes in largest component
# get largest component
getmax = function(g) {
V(g)$comp = clusters(g)$membership
delete.vertices(g, V(g)[V(g)$comp!=which(clusters(g)$csize==max(clusters(g)$csize))])
}
lc_projected_g <- getmax(projected_g)
# Turn weights into sample value!!
E(lc_projected_g)$weight <- 1
# Find shortes path from one to all nodes
p_short <- shortest.paths(lc_projected_g)
p_df <-as.data.frame(rownames(p_short))
p_df$Total_path_length <- rowSums(p_short)
# Find eigenvector centrality!!!
projected_eig <- eigen_centrality(lc_projected_g)$vector
My questions are:
In igraph weight is considered as a cost or close relationship so it is right to convert weights into same value? Even though there are many edges between Actor01 and Actor02 , the length of path will be one!
After calculated the shortest path for all nodes, there are three nodes that have the same value. In this case eigenvector centrality is the right way to find center node?
When I projected the bipartite network, I lost edge names in Actor-Actor network. How can I assign them back?
I hope that my questions are clear and reasonable. Thanks in advance.