I hope this new post be according to your tips.
My database is big so i upload it in Dropbox and here is the link to
download it:
https://www.dropbox.com/pri/get/cognitiveEdges.csv?_subject_uid=680429290&w=AADQFwqcK-l66BiR4hcJayEc8dFbn0YNHdzeJ7ErqiKr1g
and here is code to run in R studio (3.4.0) :
rm(list = ls())
library("igraph")
library("qgraph")
library("data.table")
links <- read.csv("C:/result21/CognitiveEdges.csv", header=T,
as.is=T) #
Address of file
nrow(links); nrow(unique(links[,c("From", "To")]))
nrow(unique(links[,c("From", "To")]))
net <- graph_from_data_frame(d=links, directed=T)
Q<-qgraph(as_adjacency_matrix(net))
cen<-centrality(Q)
tmp3 <- shortest.paths(net,V(net),V(net))
cen<-centrality(Q)
tmp3<-cen$ShortestPathLengths
re<-function(tmp3){
shp<-matrix(1:ncol(tmp3),ncol(tmp3),1)
for(i in ncol(tmp3))
{
shp[i,]<-max(tmp3[i,][tmp3[i,]!=Inf])}
return(shp)
}
mm<-re(tmp3)### my problem is here Line 21
max(tmp3[1,][tmp3[1,]!=Inf]) # line 22
my problem is at line 21. Why the result of mm[1,] is not same as line 22??
for other elements of mm also i didn't get the true result.
With Regards,
On Wed, Jun 21, 2017 at 9:35 AM, Jeff Newmiller <jdnewmil at
dcn.davis.ca.us>
wrote:
> Hard to follow data analysis without data. Try making your example
> reproducible [1][2][3] and post in plain text (a setting in your emailer).
> Read the Posting Guide mentioned in the footer to avoid other posting
> pitfalls.
>
> [1] http://stackoverflow.com/questions/5963269/how-to-make-
> a-great-r-reproducible-example
>
> [2] http://adv-r.had.co.nz/Reproducibility.html
>
> [3] https://cran.r-project.org/web/packages/reprex/index.html
>
> --
> Sent from my phone. Please excuse my brevity.
>
> On June 20, 2017 11:15:23 AM PDT, Zahra Tofighi <tofighizahra at
gmail.com>
> wrote:
> >hello,
> >
> >I have a graph and i use qgraph package to calculate centrality
> >parameters.
> >Now I want to know the maximum value of shortest path for each vertex
> >with
> >discarding the Inf value in short pathes. For this I use the
> >ShortestPathLengths of centrality function in qgraph. but when I want
> >to
> >get the maximum the result is wrong. here is my code:
> >
> >cen<-centrality(Q)
> >
> >tmp3<-cen$ShortestPathLengths
> >shp<-matrix(1:ncol(tmp3),ncol(tmp3),1)for(i in ncol(tmp3)){
> >shp[i,]=max(tmp3[i,][tmp3[i,]!=Inf)}
> >
> >when I display the valu of shp the result is same as initial value
> >(form
> >one to ncol). I also test with shortest.paths function. the result was
> >same. what is my wrong?
> >
> > [[alternative HTML version deleted]]
> >
> >______________________________________________
> >R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >https://stat.ethz.ch/mailman/listinfo/r-help
> >PLEASE do read the posting guide
> >http://www.R-project.org/posting-guide.html
> >and provide commented, minimal, self-contained, reproducible code.
>
[[alternative HTML version deleted]]