@@ -21,24 +21,29 @@ start.rec.log(text="NeighVsDeg")
2121
2222# read the graph
2323graph.file <- get.path.data.graph(mode = " scenes" , net.type = " static" , filtered = FALSE , pref = " graph" , ext = " .graphml" )
24+ tlog(0 ," Read the graph file: \" " ,graph.file ," \" " )
2425g <- read.graphml.file(file = graph.file )
2526
2627# compute values
28+ tlog(2 ," Compute the graph degree" )
2729deg.vals <- degree(graph = g , mode = " all" )
2830tmp <- igraph :: knn(graph = g , weights = NULL )# , mode="all", neighbor.degree.mode="all")
2931
3032# filter out zero degree and NaN
33+ tlog(2 ," Filter out zero degree nodes" )
3134idx <- which(! is.nan(tmp $ knn ) & tmp $ knn > 0 )
3235filt.nei <- tmp $ knn [idx ]
3336filt.deg <- deg.vals [idx ]
3437
3538# keep tail
39+ tlog(2 ," Keep tail" )
3640thresholds <- quantile(filt.deg , probs = c(0 ,0.25 ,0.50 ,0.75 ,0.85 ,0.90 ,0.95 ))
3741threshold <- thresholds [4 ] # exp=0.48
3842cut.nei <- filt.nei [filt.deg > = threshold ]
3943cut.deg <- filt.deg [filt.deg > = threshold ]
4044
4145# init parameters using a linear regression
46+ tlog(2 ," Perform regression" )
4247fit <- lm(log(cut.nei ) ~ log(cut.deg ))
4348summary(fit )
4449params <- fit $ coefficients
@@ -49,9 +54,9 @@ val3 <- 0
4954# perform NL regression
5055df <- data.frame (cut.deg , cut.nei )
5156fit <- nlsLM(cut.nei ~ c1 * cut.deg ^ c2 ,
52- start = list (c1 = val1 , c2 = val2 ),
53- data = df ,
54- control = list (maxiter = 200 ))
57+ start = list (c1 = val1 , c2 = val2 ),
58+ data = df ,
59+ control = list (maxiter = 200 ))
5560summary(fit )
5661
5762# plot
@@ -61,7 +66,8 @@ col.sec <- combine.colors(col, "WHITE", transparency=20)
6166xlab <- " Degree $k$"
6267ylab <- " Neighbors' average Degree $<k_{nn}>$"
6368exponent <- summary(fit )$ coefficients [" c2" ," Estimate" ]
64- plot.file <- get.path.stats.topo(net.type = " static" , mode = " scenes" , meas.name = MEAS_DEGREE , filtered = " both" , suf = " nei.deg_vs_degree" )
69+ plot.file <- get.path.stats.topo(net.type = " static" , mode = " scenes" , meas.name = MEAS_MULTI_NODES , filtered = " both" , suf = " nei-degree_vs_degree" )
70+ tlog(2 ," Plot in \" " ,plot.file ," \" " )
6571pdf(file = paste0(plot.file ,PLOT_FORMAT_PDF ), bg = " white" )
6672par(
6773 mar = c(4 ,4 ,0 ,0 )+ 0.1 , # remove the title space Bottom Left Top Right
@@ -130,6 +136,7 @@ legend(
130136
131137# ##############################################################################
132138# add the plot for the filtered net, as an inset
139+ tlog(2 ," Same thing for filtered net" )
133140
134141# filter the characters
135142filt.names <- V(g )$ name [V(g )$ Filter == " Discard" ]
0 commit comments