Reputation: 1
I am attemping to create a weighted social network between a series of characters.
I have manually created an adjacency matrix with weighted values:
. This has been linked to a separate file, in which attributes of the characters have been stored for later colouration.
My goal is to create a graph in TKplot
, where vertice size is the degree centrality, and edge width is a function of their weight.
However, when using the igraph package to generate a simpler grapher, just to test the code, I noticed that I am generating additional vertices, which appear to be duplicates of the vertices (for example, see the clear and coloured squares marked "Rusty" on the right side of the image:.
Here is the code I have written so far:
network_data<-read.csv('bbnmatrix2.csv',header=T, row.names=1, as.is=T)
bbnnames<-read.csv("bbnnames.csv", header=T, as.is=T)
net2 <- graph_from_incidence_matrix(network_data, directed = FALSE,
mode = c("total"),
multiple = FALSE,
weighted = T,
add.names = T)
plot(net2, vertex.label.color="black", vertex.label=bbnnames$name,
vertex.label.cex=0.5, edge.color="black",
vertex.color=clan, edge.width=E(net2)$weight,
vertex.shapes=bbnnames$status).
I was expecting a plot of 67 vertices, but instead generated a plot of 134.
Upvotes: -1
Views: 129
Reputation: 108
Are you trying to make a bipartite network? graph_from_incidence_matrix()
treats your input matrix as defining a bipartite network. I think you want graph_from_adjacency_matrix()
instead.
Upvotes: 0