I have a sample code in R as follows:
library(igraph)
rm(list=ls())
dat=read.csv(file.choose(),header=TRUE,row.names=1,check.names=T) # read .csv file
m=as.m
The problem seems to be due to the data-type of the matrix elements. graph.adjacency
expects elements of type numeric
. Not sure if its a bug.
After you do,
m <- as.matrix(dat)
set its mode to numeric
by:
mode(m) <- "numeric"
And then do:
net <- graph.adjacency(m, mode = "undirected", weighted = TRUE, diag = FALSE)
> E(net)$weight
[1] 8 1 10 1 15 1 1 5 7 1