0

We have an non square adjacency matrix p (197x190)matrix without weights (only 1 if the 2 telephone numbers have called with each other and 0 otherwise). We tried to visualize this with a graph using this simple code and the igraph package:

p<-as.matrix(dcast(SNA_data, A_NUMBER~B_NUMBER, value.var="W", fill=0))[,] graph<-graph.adjacency(p, mode="undirected", weighted=NULL) plot(graph)

The result is a very small graph in plot that is totally unreadable graph anybody knows how to solve this?

Thanks in advance.

olive
  • 179
  • 1
  • 11

2 Answers2

0

Try to use x11() to plot your graph in an external window :

library(igraph)
adjm1<-matrix(sample(0:1,1000,replace=TRUE,prob=c(0.9,01)),nc=10) 
g1<-graph.adjacency(adjm1)
x11()
plot(g1)

Reference for the simulation : using graph.adjacency() in R

Community
  • 1
  • 1
Smich7
  • 460
  • 2
  • 14
  • If that not work on your matrix you should give an entire code with almost a portion of your matrix. – Smich7 Apr 01 '17 at 11:00
  • Error in .Call("R_igraph_graph_adjacency", adjmatrix, as.numeric(mode), : At structure_generators.c:272 : Non-square matrix, Non-square matrix – olive Apr 01 '17 at 12:23
  • I added some more information in my question, hope this helps! – olive Apr 01 '17 at 12:50
  • 1
    If I unserstand your matrix has phone numbers in column and row's IDs. As I can see in the R help,`graph.adjency` only accept squard matrix. That's not possible that your matrix is non-squared espicially if you want to make a such graph. – Smich7 Apr 01 '17 at 14:44
0

If your matrix is not a square, it might be worth trying an incidence matrix. By default the matrix is directed from rows to columns.

# create the network object
network <- graph_from_incidence_matrix(p)
network

class(network)

# plot it
plot(network)
user438383
  • 5,716
  • 8
  • 28
  • 43