[R] Weighted Graph Link strength ( I am making mistake please help)
Sur Nathan
surendar.swaminathan at gmail.com
Wed Mar 25 19:56:40 CET 2009
Hello R experts,
I went through R mailing,Nabble R.I could not find solution.Can someone
help me.
I have undirected Graph.
Here is an example of spreadsheet I have( Unique 3559 Nodes)
snippet of 4 rows.
Node1 Node2 Weights
1 2 5
2 3 30
2 4 30
1 4 5
3 4 30
1 3 2
I created a program reading the csv and created a Adjacency matrix.From the
adjacency matrix I created graph.I am not sure the mistake I am making.
Program to read and create Matrix
matrixmy<-scan("test.csv",sep=",",skip=1)
arr=array(0,dim=c(4,4))
a<-1
while(a<=length(matrixmy))
{
i=matrixmy[a]
a<-a+1
j=matrixmy[a]
a<-a+1
k=matrixmy[a]
arr[i,j]<-k
arr[j,i]<-k
a<-a+1
}
Created matrix
mat1<-matrix(data=arr,nrow=4,ncol=4)
g<-graph.adjacency(adjmatrix=mat1,mode=c("undirected"))
betweenness(g)
The answer I get is
0 0 0 0
I was expecting Node 1 will have high value.
Can someone tell me why it is happening like this.
Thanks in advance.
Nathna
--
View this message in context: http://www.nabble.com/Weighted-Graph-Link-strength-%28-I-am-making-mistake-please-help%29-tp22707957p22707957.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list