-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.xml
More file actions
2052 lines (1582 loc) · 115 KB
/
index.xml
File metadata and controls
2052 lines (1582 loc) · 115 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Vienna R User Group </title>
<link>/</link>
<language>en-us</language>
<author>Vienna-R</author>
<rights>(C) 2019</rights>
<updated>2019-02-12 00:00:00 +0000 UTC</updated>
<item>
<title>Meetup 02-2019 Minutes</title>
<link>/blog/2019/02/12/february-2019-meetup/</link>
<pubDate>Tue, 12 Feb 2019 00:00:00 UTC</pubDate>
<author>Vienna-R</author>
<guid>/blog/2019/02/12/february-2019-meetup/</guid>
<description>
<h2 id="self-service-data-preparation-und-data-science">Self Service Data Preparation und Data Science</h2>
<p><a href="https://www.linkedin.com/in/peter-jeitschko-3aa02179"><strong>Peter Jeitschko</strong></a></p>
<p>Peter presented Alteryx, a platform built for Business Analysts to master tasks like data management, data cleaning and modelling. The tool is windows only and will be ported to Linux soon. It can connect to multiple data sources and helps Business Analysts to deploy models in production. Finally, Peter also showed a Demo including data ingestion, an example of the Facebook Face API and some community features.</p>
<p>You can find the <strong>slides</strong> of his presentation <a href="/slides/Alteryx Corporate Intro Presentation.pptx">here</a>.</p>
<h3 id="questions">Questions</h3>
<p><strong>Do you have scheduling capabilities (for metadata, e.g. <a href="https://atlas.apache.org/">Atlas</a>)?</strong><br>
Yes - Alteryx has scheduling capabilities server side and on the desktop.</p>
<p><strong>Who is the target audience?</strong><br>
Business Analysts, business users?</p>
<p><strong>How does it scale to millions of rows? Does it run in parallel?</strong><br>
Yes, to many CPU&rsquo;s -&gt; Large Server</p>
<p><strong>Which language is behind Alteryx/ what is running behind the scenes?</strong><br>
C++?</p>
<p><strong>How much?</strong><br>
€5195 per user per year, see also</p>
<p><strong>Who are the competitors?</strong><br>
Knime (Open Source), Data Iku</p>
<h2 id="grpc-xmlrpc-in-r">grpc + xmlrpc in R</h2>
<p><a href="https://www.wu.ac.at/statmath/faculty-staff/faculty/fschwendinger"><strong>Florian Schwendinger</strong></a></p>
<p>Florian presented the package gRPC to interface the popular RPC framework, see also <a href="https://github.com/nfultz/grpc">https://github.com/nfultz/grpc</a>. The reason to use gRPC instead of REST APIs is performance since messages are sent via <a href="http://dirk.eddelbuettel.com/code/rprotobuf.html">protobuf</a> instead of JSON.</p>
<p>You can find the <strong>slides</strong> <a href="/slides/grpc.pdf">here</a>.</p>
<h2 id="serverless-computing-with-aws-for-data-science">Serverless Computing with AWS for data science</h2>
<p><a href="https://www.linkedin.com/in/christoph-bodner"><strong>Christoph Bodner</strong></a> and <a href="https://www.linkedin.com/in/thomas-laber"><strong>Thomas Laber</strong></a></p>
<p>Christoph and Thomas presented a way to use R within AWS lambda functions for model deployment - thus making R functions serverless. The reasons for using lambda functions is no administration, scalability and pay per user schemes (GB/secs) allowing for fast turnarounds.</p>
<p>However, they also mentioned limitations and challenges deploying R as lambda functions including memory and space limits and suggested using managed container services as alternatives.</p>
<p>Below the materials of their presentation:</p>
<ul>
<li><strong>Slides</strong>: <a href="/slides/Serverless Computing.pdf">Serverless Computing</a></li>
<li><strong>Article</strong>: <a href="https://medium.com/bakdata/running-r-on-aws-lambda-9d40643551a6">https://medium.com/bakdata/running-r-on-aws-lambda-9d40643551a6</a></li>
</ul>
</description>
</item>
<item>
<title>Meetup 11-2016 Minutes</title>
<link>/blog/2016/11/22/meetup-11-2016-minutes/</link>
<pubDate>Tue, 22 Nov 2016 13:00:00 +0200</pubDate>
<author>Vienna-R</author>
<guid>/blog/2016/11/22/meetup-11-2016-minutes/</guid>
<description><p><img src="/img/deepnet.png" title="**Deep Neural Network**" \
alt="**Deep Neural Network**" border="0" /></p>
<p>Deep learning with R using <strong>mxnet</strong></p>
<p>During the November ViennaR Meetup Klaudius Kalcher gave an excellent talk about the <strong>mxnet</strong> package. After covering some theoretical background he included examples to build deep neural networks from scratch.
Finally, Mario showed some time series forecasting examples already discussing during the October Meetup using the <strong>forecast</strong> package.</p>
<h2 id="links">Links</h2>
<ul>
<li><strong>mxnet</strong>
<ul>
<li><a href="/slides/kalcher_deeplearning.pdf">Slides</a></li>
<li><strong>mxnet</strong> R-package: <a href="https://github.com/dmlc/mxnet/tree/master/R-package">https://github.com/dmlc/mxnet/tree/master/R-package</a></li>
<li>dmlc mxnet for Deep Learning: <a href="http://mxnet.io">http://mxnet.io</a></li>
</ul></li>
<li><strong>forecast</strong>
<ul>
<li><a href="/slides/forecast_intro2.html">Forecasting Crashcourse</a> (<a href="/slides/forecast_intro2.Rmd">src</a>)</li>
<li><strong>forecast</strong> package: <a href="https://CRAN.R-project.org/package=forecast">https://CRAN.R-project.org/package=forecast</a></li>
<li>Forecasting: principles and practice book: <a href="https://www.otexts.org/fpp">https://www.otexts.org/fpp</a></li>
</ul></li>
</ul>
<p>Merry Christmas and a happy new coding year!</p>
<p>Yours,</p>
<p>ViennaR</p></description>
</item>
<item>
<title>Meetup 10-2016 Minutes</title>
<link>/blog/2016/10/19/meetup-10-2016-minutes/</link>
<pubDate>Wed, 19 Oct 2016 13:00:00 CEST</pubDate>
<author>Vienna-R</author>
<guid>/blog/2016/10/19/meetup-10-2016-minutes/</guid>
<description><p><img src="/img/meetup_201610_small.jpg" title="**sparklyr**" \
alt="**sparklyr**" style='width:70%;' border="0" /></p>
<p>A <strong>sparklyr</strong> introduction by Roland Boubela.</p>
<p>The October Meetup was hosted by Roland Boubela who gave an excellent talk about the new <strong>sparklyr</strong> package. <strong>sparklyr</strong> provides an easy-to-use interface to Apache Spark and can even be accessed using the latest and greatest version of RStudio (<a href="https://www.rstudio.com/products/rstudio/download/preview">preview release</a>). It also covered a comparison with the existing <strong>SparkR</strong> package.</p>
<h2 id="links">Links</h2>
<ul>
<li><a href="/slides/boubela_sparklyr.pdf">Slides</a></li>
<li><strong>sparklyr</strong>: <a href="http://spark.rstudio.com">http://spark.rstudio.com</a></li>
<li><strong>SparkR</strong>: <a href="http://spark.apache.org/docs/latest/sparkr.html">http://spark.apache.org/docs/latest/sparkr.html</a></li>
<li>RStudio Preview: <a href="https://www.rstudio.com/products/rstudio/download/preview">https://www.rstudio.com/products/rstudio/download/preview</a></li>
<li>Apache Spark: <a href="http://spark.apache.org">http://spark.apache.org</a></li>
</ul>
<p>Best,</p>
<p>-ViennaR</p></description>
</item>
<item>
<title>Meetup 09-2016 Minutes</title>
<link>/blog/2016/09/27/meetup-09-2016-minutes/</link>
<pubDate>Tue, 27 Sep 2016 13:00:00 CEST</pubDate>
<author>Vienna-R</author>
<guid>/blog/2016/09/27/meetup-09-2016-minutes/</guid>
<description><p><img src="/img/meetup_201609_small.jpg" title="**Brainstorm Forecasting**" \
alt="**Brainstorm Forecasting**" style='width:70%;' border="0" /></p>
<p>A brainstorming session about forecasting time series in R.</p>
<p>First we discussed the topic data structures. Regular time series data can be represented using the <em>ts</em> class which is already included in the basic R installation (as part of the <strong>stats</strong> package). By contrast, irregular time series data can be represented by the popular <strong>zoo</strong> objects (or <strong>xts</strong>). Most (ARIMA-)forecasting methods require regular time series.</p>
<p>The following R packages have been identified to support time series forecasting:</p>
<ul>
<li><a href="https://CRAN.R-project.org/package=forecast"><strong>forecast</strong></a>: Excellent package by Rob Hyndman supporting all kinds of ARIMA models; even includes an automatic forecasting function (<em>auto.arima</em>).</li>
<li><a href="https://CRAN.R-project.org/package=tseries"><strong>tseries</strong></a>: Package supporting basic ARIMA model but also includes GARCH for volatility forecasting.</li>
<li><a href="https://cran.r-project.org/package=x12"><strong>x12</strong></a>: Interface package to the X12-ARIMA program for sesonal adjustment</li>
<li><a href="https://cran.r-project.org/package=seasonal"><strong>seasonal</strong></a>: Interface package to the X-13-ARIMA-SEATS program for sesonal adjustment.</li>
</ul>
<h2 id="projects">Projects</h2>
<p>The following potential projects covering simple time series forecasting examples have been discussed/requested:</p>
<ul>
<li>Google Trends data (e.g. <em>Influenza</em>)</li>
<li>Company data, e.g. Revenues</li>
<li>Bike Traffic in Vienna</li>
<li>Stock Prices, Volatility (GARCH)</li>
<li>Birdlife data, see data for Bavaria e.g.
<a href="http://www.stunde-der-wintervoegel.de/index.php?id=auswertung&amp;land=Bayern">2016</a>,
<a href="http://sdw2015.lbv.de/index.php?id=auswertung&amp;land=Bayern">2015</a>,
<a href="http://sdw2014.lbv.de/index.php?id=auswertung&amp;land=Bayern">2014</a>,
<a href="http://sdw2013.lbv.de/index.php?id=auswertung&amp;land=Bayern">2013</a>,
<a href="http://sdw2012.lbv.de/index.php?id=auswertung&amp;land=Bayern">2012</a>,
<a href="http://sdw2011.lbv.de/index.php?id=auswertung&amp;land=Bayern">2011</a>,
<a href="http://sdw2010.lbv.de/index.php?id=auswertung&amp;land=Bayern">2010</a>,
<a href="http://sdw2009.lbv.de/index.php?id=auswertung&amp;land=Bayern">2009</a></li>
</ul>
<p>The projects will be presented during the November R-Meetup (contributions welcome!).</p>
<h2 id="announcements">Announcements</h2>
<p>The next meetup will cover the <a href="http://spark.rstudio.com"><strong>sparklyr</strong></a> package presented by Roland Boubela.</p>
<p>Best,</p>
<p>-ViennaR</p></description>
</item>
<item>
<title>igraph Applications for Transportation Networks</title>
<link>/blog/2016/08/24/igraph-applications-for-transportation-networks/</link>
<pubDate>Wed, 24 Aug 2016 22:20:00 CEST</pubDate>
<author>Vienna-R</author>
<guid>/blog/2016/08/24/igraph-applications-for-transportation-networks/</guid>
<description>
<p>Materials from Max Leodolters talk in May covering the <strong>igraph</strong> package.</p>
<pre class="r"><code>require(igraph)
require(data.table)
require(ggplot2)</code></pre>
<div id="centrality---what-is-it" class="section level1">
<h1>Centrality - What is it?</h1>
<p>Network Centrality gives you an idea of how important a vertex/node and edge/link in your network/graph <span class="math inline">\(N(V,E)\)</span> respectively <span class="math inline">\(G(N,L)\)</span> is. Examples:</p>
<ul>
<li>Closeness</li>
<li>Betweenness</li>
<li>Eigenvalue</li>
<li>degree</li>
<li>…</li>
</ul>
<p>Some formulas:</p>
<ul>
<li>Closeness Centrality <span class="math display">\[ C^{node}(n) = \frac{1}{\sum_{m \in N \setminus \{n\}}d(n,m)} \]</span></li>
<li>Betweenness centrality <span class="math display">\[ B^{node}(n) = \sum_{m\neq o \in N\backslash \{n\} } \frac{\sigma_{mo}(n)}{\sigma_{mo}} \]</span></li>
<li>Node-based Closeness for a link <span class="math display">\[ \ddot{C}^{link}(l_{n,m}) = \frac{C^{node}(n) + C^{node}(m)}{2} \]</span></li>
<li>Node-based Betweenness for a link <span class="math display">\[ \ddot{B}^{link}(l_{n,m}) = \frac{B^{node}(n) + B^{node}(m)}{2} \]</span></li>
<li>Link-based Betweenness for a link <span class="math display">\[ B^{link}(l) = \sum_{n \neq m \in N } \frac{\sigma_{nm}(l)}{\sigma_{nm}} \]</span> *<span class="math inline">\(\sigma\)</span> is the number of traversing OD relations, and <span class="math inline">\(d(n,m)\)</span> is the distance of the shortest route from <span class="math inline">\(n\)</span> to <span class="math inline">\(m\)</span></li>
</ul>
<p>What to select, <span class="math inline">\(\ddot{B}^{link}(l_{n,m})\)</span> or <span class="math inline">\(B^{link}(l)\)</span>?</p>
</div>
<div id="igraph-for-centralities" class="section level1">
<h1>igraph for centralities</h1>
<div id="node-betweenness" class="section level2">
<h2>Node Betweenness</h2>
<pre class="r"><code>g &lt;- make_star(5, mode = &quot;undirected&quot;, center=3)
V(g)$name &lt;- letters[1:length(V(g))]
plot(g)</code></pre>
<p><img src="/post/20160524_igraph_applications_files/figure-html/unnamed-chunk-2-1.png" width="672" /></p>
<pre class="r"><code>g &lt;- set.edge.attribute(g, &quot;weight&quot;, value= 1)
b &lt;- betweenness(g, directed=F)
V(g)$name &lt;- b
plot(g)</code></pre>
<p><img src="/post/20160524_igraph_applications_files/figure-html/unnamed-chunk-2-2.png" width="672" /></p>
<p>Edge Betweenness:</p>
<pre class="r"><code>g &lt;- make_star(5, mode = &quot;undirected&quot;, center=3)
V(g)$name &lt;- letters[1:length(V(g))]
g &lt;- set.edge.attribute(g, &quot;weight&quot;, value= 1)
bg &lt;- edge_betweenness(g, directed=F)
plot(g, edge.label = bg)</code></pre>
<p><img src="/post/20160524_igraph_applications_files/figure-html/unnamed-chunk-3-1.png" width="672" /></p>
</div>
<div id="local-vs.global" class="section level2">
<h2>Local vs. Global</h2>
<pre class="r"><code>g &lt;- make_graph(c(1, 2, 2, 3,#horizontal connections
4,5,5,6,6,7,
1,6,#vertical connections
2,7), directed = FALSE)
#g &lt;- make_star(10, mode = &quot;undirected&quot;, center=3)
V(g)$name &lt;- letters[1:length(V(g))]
g &lt;- set.edge.attribute(g, &quot;weight&quot;, value= 1)
set.seed(2)
lay &lt;- layout.auto(g)
bl &lt;- estimate_edge_betweenness(g, cutoff = 1.5, directed=F);bl</code></pre>
<pre><code>## [1] 3 3 2 4 3 3 3</code></pre>
<pre class="r"><code>bg &lt;- edge_betweenness(g, directed=F)
# set plotting parameters
vs &lt;- 15# vertex.size
ec &lt;- gray(0.8)#edge.color
elx &lt;- 2# edge.label.cex
elc &lt;- &quot;black&quot;#,edge.label.color
vlc &lt;- 2#vertex.label.cex
ew &lt;- 2#edge.width
hd &lt;- paste(rep(&quot; &quot;,0), collapse=&quot;&quot;)
cm &lt;- 3
vc &lt;- &quot;orange&quot;#gray(0.8)#palette(&quot;default&quot;)#&quot;grey&quot;#vertex.color
#windows(width = 18, height=6)
#par(mfrow=c(1,3))
plot(g, edge.label=paste(hd, round(E(g)$weight,1)), layout=lay, vertex.size=vs, edge.color=ec, edge.label.cex=elx, vertex.label.cex=vlc, edge.width=ew, edge.label.color=elc, vertex.color=vc)
title(&quot;(a) Weights&quot;, cex.main = cm)</code></pre>
<p><img src="/post/20160524_igraph_applications_files/figure-html/unnamed-chunk-4-1.png" width="672" /></p>
<pre class="r"><code>plot(g, edge.label=paste(hd, round(bl,1)), layout=lay, vertex.size=vs, edge.color=ec, edge.label.cex=elx, vertex.label.cex=vlc, edge.width=ew, edge.label.color=elc, vertex.color=vc)
title(&quot;(b) Local Betweenness&quot;, cex.main = cm)</code></pre>
<p><img src="/post/20160524_igraph_applications_files/figure-html/unnamed-chunk-4-2.png" width="672" /></p>
<pre class="r"><code>plot(g, edge.label=paste(hd, round(bg,1)), layout=lay, vertex.size=vs, edge.color=ec, edge.label.cex=elx, vertex.label.cex=vlc, edge.width=ew, edge.label.color=elc, vertex.color=vc)
title(&quot;(c) Global Betweenness&quot;, cex.main = cm)</code></pre>
<p><img src="/post/20160524_igraph_applications_files/figure-html/unnamed-chunk-4-3.png" width="672" /></p>
</div>
<div id="node-based-vs.link-based-betweenness-for-links" class="section level2">
<h2>Node-based vs. link-based Betweenness for Links</h2>
<pre class="r"><code>g &lt;- make_graph(c(1,2, 2,3, 3,4, 4,5,#horizontal connections
6,7, 7,8, 8,9, 9,10,
2,7,#vertical connections
3,8,
4,9), directed = FALSE)
V(g)$name &lt;- letters[1:length(V(g))]
set.seed(1210)
g &lt;- set.edge.attribute(g, &quot;weight&quot;, value= 1)
g &lt;- set.edge.attribute(g, &quot;weight&quot;, index= c(10), value= 2)
#plot(g,edge.label=paste(hd, round(E(g)$weight,1)))
lay &lt;- layout.auto(g)
eb &lt;- edge_betweenness(g, directed=F)
vb &lt;- betweenness(g, directed=F)
tmp1 &lt;- as.data.table(as.data.frame(cbind(get.edgelist(g))))
tmp1[,id:=1:.N]
tmp2 &lt;- as.data.table(data.frame(value=vb, name=names(vb)))
setnames(tmp1, &quot;V1&quot;, &quot;name&quot;)
tmp3 &lt;- merge(tmp1, tmp2, by =&quot;name&quot;)
setnames(tmp3, &quot;name&quot;, &quot;V1&quot;)
setnames(tmp3, &quot;V2&quot;, &quot;name&quot;)
tmp4 &lt;- merge(tmp3, tmp2, by =&quot;name&quot;)
setnames(tmp4, &quot;name&quot;, &quot;V2&quot;)
tmp4[,m:=mean(c(value.x, value.y)) , by=c(&quot;V2&quot;,&quot;V1&quot;)]
evb &lt;- tmp4[order(id),list(V1,V2,m)]$m
# set plotting parameters
vs &lt;- 15# vertex.size
ec &lt;- &quot;grey&quot;#edge.color
elx &lt;- 2# edge.label.cex
elc &lt;- &quot;black&quot;#edge.label.color
vlc &lt;- 2#vertex.label.cex
ew &lt;- 2#edge.width
hd &lt;- paste(rep(&quot; &quot;,0), collapse=&quot;&quot;)
cm &lt;- 3
vc &lt;- &quot;orange&quot;# vertex.color
X11(width = 18, height=6)
#par(mfrow=c(1,3))
plot(g, edge.label=paste(hd, round(E(g)$weight,1)), layout=lay, vertex.size=vs, edge.color=ec, edge.label.cex=elx, vertex.label.cex=vlc, edge.width=ew, edge.label.color=elc, vertex.color=vc)
title(&quot;(a) Weights&quot;,cex.main=cm)</code></pre>
<p><img src="/post/20160524_igraph_applications_files/figure-html/unnamed-chunk-5-1.png" width="672" /></p>
<pre class="r"><code>plot(g, edge.label=paste(hd, round(eb,1)), layout=lay, vertex.size=vs, edge.color=ec, edge.label.cex=elx, vertex.label.cex=vlc, edge.width=ew, edge.label.color=elc, vertex.color=vc)
title(&quot;(b) Link based Betweenness&quot;,cex.main=cm)</code></pre>
<p><img src="/post/20160524_igraph_applications_files/figure-html/unnamed-chunk-5-2.png" width="672" /></p>
<pre class="r"><code>V(g)$name &lt;- paste(vb)
plot(g, edge.label=paste(hd, round(evb,1)), layout=lay, vertex.size=vs, edge.color=ec, edge.label.cex=elx, vertex.label.cex=vlc, edge.width=ew, edge.label.color=elc, vertex.color=vc)
title(&quot;(c) Node based Betweenness&quot; ,cex.main=cm)</code></pre>
<p><img src="/post/20160524_igraph_applications_files/figure-html/unnamed-chunk-5-3.png" width="672" /></p>
</div>
<div id="bugsfeaturesspecial-experiences" class="section level2">
<h2>Bugs/Features/Special experiences</h2>
<ul>
<li>demonstrate the parameter ‘lay’ with setting it NULL</li>
<li>cutoff parameter</li>
<li>nodes need to be named for using induced.subgraph(), otherwise problems in matching results</li>
</ul>
<div id="cutoff" class="section level3">
<h3>cutoff</h3>
<p>stackoverflow: <a href="http://stackoverflow.com/questions/34180036/how-does-the-cutoff-parameter-influence-betweenness-calculation" class="uri">http://stackoverflow.com/questions/34180036/how-does-the-cutoff-parameter-influence-betweenness-calculation</a></p>
<p>discussion: <a href="https://lists.nongnu.org/archive/html/igraph-help/2012-11/msg00083.html" class="uri">https://lists.nongnu.org/archive/html/igraph-help/2012-11/msg00083.html</a></p>
<p>github project: <a href="https://github.com/maxar/igraph_testing/blob/master/test_vertex_betweenness_local.R" class="uri">https://github.com/maxar/igraph_testing/blob/master/test_vertex_betweenness_local.R</a></p>
<pre class="r"><code>require(igraph)
packageVersion(&quot;igraph&quot;) # my installed version is 1.0.1</code></pre>
<pre><code>## [1] &#39;1.2.2&#39;</code></pre>
<pre class="r"><code>#----------------------------------------------------------------------------------------
#--------------- EXAMPLE 1 --------------------------------------------------------
#----------------------------------------------------------------------------------------
#--- set plotting parameters
vs &lt;- 25# vertex.size
ec &lt;- gray(0.8)#edge.color
elx &lt;- 2# edge.label.cex
elc &lt;- &quot;black&quot;#,edge.label.color
vlc &lt;- 2#vertex.label.cex
ew &lt;- 2#edge.width
cm &lt;- 2
vc &lt;- &quot;orange&quot;
g &lt;- make_graph(c(1, 2, 2, 3, 3, 4, 4,5, 5, 6, 6, 7) , directed = FALSE)
set.seed(1210)
lay &lt;- layout.auto(g)
graphics.off()
X11(width = 30, height=10)
#par(mfrow=c(1,3))
V(g)$name &lt;- letters[1:length(V(g))]
g &lt;- set.edge.attribute(g, &quot;weight&quot;, value= c(2,3,5,5,3,2))
plot(g, edge.label=round(E(g)$weight,1), layout=lay, vertex.size=vs, edge.color=ec, edge.label.cex=elx, vertex.label.cex=vlc, edge.width=ew, edge.label.color=elc, vertex.color=vc)
title(&quot;(a) Weights&quot;, cex.main = cm)</code></pre>
<p><img src="/post/20160524_igraph_applications_files/figure-html/unnamed-chunk-6-1.png" width="672" /></p>
<pre class="r"><code>bl.1 &lt;- estimate_betweenness(g, cutoff=10)
V(g)$name &lt;- bl.1
plot(g, layout=lay, vertex.size=vs, edge.color=ec, edge.label.cex=elx, vertex.label.cex=vlc, edge.width=ew, edge.label.color=elc, vertex.color=vc)
title(&quot;(b) Local Betweenness\ncutoff 10&quot;, cex.main = cm)</code></pre>
<p><img src="/post/20160524_igraph_applications_files/figure-html/unnamed-chunk-6-2.png" width="672" /></p>
<pre class="r"><code>bl.2 &lt;- estimate_betweenness(g, cutoff=Inf)
V(g)$name &lt;- bl.2
plot(g, layout=lay, vertex.size=vs, edge.color=ec, edge.label.cex=elx, vertex.label.cex=vlc, edge.width=ew, edge.label.color=elc, vertex.color=vc)
title(&quot;(b) Global Betweenness\ncutoff Inf&quot;, cex.main = cm)</code></pre>
<p><img src="/post/20160524_igraph_applications_files/figure-html/unnamed-chunk-6-3.png" width="672" /></p>
<pre class="r"><code># Comments and Discussion:
# This simple example illustrates, why it is questionable
# that the cutoff parameter actually measures distance independent of the edge weights
#
# 1. define edge weights as in plot (a)
# 2. calculate vertex betweenness with cutoff 10 (b)
# 3. calculate vertex betweenness with cutoff Inf (c)
#----------------------------------------------------------------------------------------
#--------------- EXAMPLE 2 --------------------------------------------------------
#----------------------------------------------------------------------------------------
#--- set plotting parameters
vs &lt;- 25# vertex.size
ec &lt;- gray(0.8)#edge.color
elx &lt;- 2# edge.label.cex
elc &lt;- &quot;black&quot;#,edge.label.color
vlc &lt;- 2#vertex.label.cex
ew &lt;- 2#edge.width
cm &lt;- 2
vc &lt;- &quot;orange&quot;
set.seed(1210)
g &lt;- make_ring(8)
lay &lt;- layout.auto(g)
graphics.off()
X11(width = 12, height=12)
par(mfrow=c(2,2))
V(g)$name &lt;- letters[1:length(V(g))]
g &lt;- set.edge.attribute(g, &quot;weight&quot;, value= c(.1 , .2, rep(.1, 2), rep(0.2,4)))
plot(g, edge.label=round(E(g)$weight,1), layout=lay, vertex.size=vs, edge.color=ec, edge.label.cex=elx, vertex.label.cex=vlc, edge.width=ew, edge.label.color=elc, vertex.color=vc)
title(&quot;(a) Weights&quot;, cex.main = cm)
bl.1 &lt;- estimate_betweenness(g, cutoff=0.29)
V(g)$name &lt;- bl.1
plot(g, layout=lay, vertex.size=vs, edge.color=ec, edge.label.cex=elx, vertex.label.cex=vlc, edge.width=ew, edge.label.color=elc, vertex.color=vc)
title(&quot;(b) Local Betweenness\ncutoff 0.29&quot;, cex.main = cm)
V(g)$name &lt;- letters[1:length(V(g))]
g &lt;- set.edge.attribute(g, &quot;weight&quot;, value=.2)
plot(g, edge.label=round(E(g)$weight,1), layout=lay, vertex.size=vs, edge.color=ec, edge.label.cex=elx, vertex.label.cex=vlc, edge.width=ew, edge.label.color=elc, vertex.color=vc)
title(&quot;(c) new weights&quot;, cex.main = cm)
bl.2 &lt;- estimate_betweenness(g, cutoff=0.29)
V(g)$name &lt;- bl.2
plot(g, layout=lay, vertex.size=vs, edge.color=ec, edge.label.cex=elx, vertex.label.cex=vlc, edge.width=ew, edge.label.color=elc, vertex.color=vc)
title(&quot;(d) Local Betweenness\ncutoff 0.29&quot;, cex.main = cm)</code></pre>
<p><img src="/post/20160524_igraph_applications_files/figure-html/unnamed-chunk-6-4.png" width="672" /></p>
<pre class="r"><code># Comments and Discussion:
# This simple example illustrates, that vertex betweenness values change,
# if the edge weights are changed and the cutoff parameters are chosen constant.
# Ring shape to reconstruct the calculation easier;
#
# 1. define edge weights as in plot (a)
# 2. calculate vertex betweenness with cutoff 0.29 (b)
# 3. define new edge weights as in plot (c)
# 4. calculate vertex betweenness with cutoff 0.29 (d)
#----------------------------------------------------------------------------------------
#--------------- EXAMPLE 3 --------------------------------------------------------
#----------------------------------------------------------------------------------------
#--- set plotting parameters
vs &lt;- 20# vertex.size
ec &lt;- gray(0.8)#edge.color
elx &lt;- 1# edge.label.cex
elc &lt;- &quot;black&quot;#,edge.label.color
vlc &lt;- 1#vertex.label.cex
ew &lt;- 2#edge.width
cm &lt;- 2
vc &lt;- &quot;orange&quot;
set.seed(1210)
g &lt;- make_ring(20)
lay &lt;- layout.auto(g)
graphics.off()
#windows(width = 30, height=30)
#par(mfrow=c(2,2))
V(g)$name &lt;- letters[1:length(V(g))]
g &lt;- set.edge.attribute(g, &quot;weight&quot;, value= c(rep(2:3,10)))
plot(g, edge.label=round(E(g)$weight,1), layout=lay, vertex.size=vs, edge.color=ec, edge.label.cex=elx, vertex.label.cex=vlc, edge.width=ew, edge.label.color=elc, vertex.color=vc)
title(&quot;(a) Weights&quot;, cex.main = cm)
bl.1 &lt;- estimate_betweenness(g, cutoff=6)
V(g)$name &lt;- bl.1
plot(g, layout=lay, vertex.size=vs, edge.color=ec, edge.label.cex=elx, vertex.label.cex=vlc, edge.width=ew, edge.label.color=elc, vertex.color=vc)
title(&quot;(b) Local Betweenness\ncutoff 6&quot;, cex.main = cm)
bl.2 &lt;- estimate_betweenness(g, cutoff=9)
V(g)$name &lt;- bl.2
plot(g, layout=lay, vertex.size=vs, edge.color=ec, edge.label.cex=elx, vertex.label.cex=vlc, edge.width=ew, edge.label.color=elc, vertex.color=vc)
title(&quot;(c) Local Betweenness\ncutoff 9&quot;, cex.main = cm)
bl.3 &lt;- estimate_betweenness(g, cutoff=Inf)
V(g)$name &lt;- bl.3
plot(g, layout=lay, vertex.size=vs, edge.color=ec, edge.label.cex=elx, vertex.label.cex=vlc, edge.width=ew, edge.label.color=elc, vertex.color=vc)
title(&quot;(d) Global Betweenness\ncutoff Inf&quot;, cex.main = cm)
# Comments and Discussion:
# This simple example illustrates, that vertex betweenness values change,
# if the edge weights are constant and the cutoff parameters change.
# Ring shape to reconstruct the calculation easier;
#
# 1. define edge weights as in plot (a)
# 2. calculate vertex betweenness with cutoff 6 (b)
# 3. calculate vertex betweenness with cutoff 9 (c)
# 4. calculate vertex betweenness with cutoff Inf (d)</code></pre>
</div>
<div id="normalization" class="section level3">
<h3>normalization</h3>
<p>stackoverflow: <a href="http://stackoverflow.com/questions/34000326/normalized-local-closeness-centrality-in-r-igraphestimate-closeness" class="uri">http://stackoverflow.com/questions/34000326/normalized-local-closeness-centrality-in-r-igraphestimate-closeness</a></p>
<p>I am trying to calculate a normalized local closeness centrality. But setting the parameter ‘normalized = T’ for igraph::estimate_closeness() only multiplies the results with (N-1). Is it possible to define N_i for vertex i individually by it’s neighborhood, that is determined by the cut-off parameter (and of course by the graph itself)?</p>
<p>The mini example demonstrates, that setting the parameter ‘normalized=T’ does not work for this purpose. It normalizes with one and the same (N-1) for all vertices.</p>
<p>Thanks for help.</p>
<pre class="r"><code>set.seed(1210)
require(&#39;igraph&#39;)
g &lt;- random.graph.game(20,3/10)
g &lt;- set.edge.attribute(g, &quot;weight&quot;, value= 1)
cnt &lt;- estimate_closeness(g, cutoff = 3, normalized = T );cnt</code></pre>
<pre><code>## Warning in estimate_closeness(g, cutoff = 3, normalized = T): At
## centrality.c:2617 :closeness centrality is not well-defined for
## disconnected graphs</code></pre>
<pre><code>## [1] 0.6333333 0.2467532 0.3220339 0.5000000 0.5277778 0.5588235 0.6129032
## [8] 0.5135135 0.5428571 0.5588235 0.4634146 0.5277778 0.6129032 0.5000000
## [15] 0.6333333 0.5000000 0.3392857 0.5135135 0.5135135 0.5135135</code></pre>
<pre class="r"><code>cnf &lt;- estimate_closeness(g, cutoff = 3, normalized = F );cnf</code></pre>
<pre><code>## Warning in estimate_closeness(g, cutoff = 3, normalized = F): At
## centrality.c:2617 :closeness centrality is not well-defined for
## disconnected graphs</code></pre>
<pre><code>## [1] 0.03333333 0.01298701 0.01694915 0.02631579 0.02777778 0.02941176
## [7] 0.03225806 0.02702703 0.02857143 0.02941176 0.02439024 0.02777778
## [13] 0.03225806 0.02631579 0.03333333 0.02631579 0.01785714 0.02702703
## [19] 0.02702703 0.02702703</code></pre>
<pre class="r"><code>#print results
cbind(cnf * (length(V(g))-1), cnt)</code></pre>
<pre><code>## cnt
## [1,] 0.6333333 0.6333333
## [2,] 0.2467532 0.2467532
## [3,] 0.3220339 0.3220339
## [4,] 0.5000000 0.5000000
## [5,] 0.5277778 0.5277778
## [6,] 0.5588235 0.5588235
## [7,] 0.6129032 0.6129032
## [8,] 0.5135135 0.5135135
## [9,] 0.5428571 0.5428571
## [10,] 0.5588235 0.5588235
## [11,] 0.4634146 0.4634146
## [12,] 0.5277778 0.5277778
## [13,] 0.6129032 0.6129032
## [14,] 0.5000000 0.5000000
## [15,] 0.6333333 0.6333333
## [16,] 0.5000000 0.5000000
## [17,] 0.3392857 0.3392857
## [18,] 0.5135135 0.5135135
## [19,] 0.5135135 0.5135135
## [20,] 0.5135135 0.5135135</code></pre>
<pre class="r"><code>sum(abs(cnf * (length(V(g))-1) - cnt))</code></pre>
<pre><code>## [1] 8.326673e-17</code></pre>
<pre class="r"><code>#for visualization
V(g)$name &lt;- paste(&quot;v&quot;, 1:length(V(g)), sep=&quot;&quot;)#letters[1:length(V(g))]
set.seed(2)
lay &lt;- layout.auto(g)
## set plotting parameters
vs &lt;- 15# vertex.size
ec &lt;- gray(0.8)#edge.color
elx &lt;- 2# edge.label.cex
elc &lt;- &quot;black&quot;#,edge.label.color
vlc &lt;- 2#vertex.label.cex
ew &lt;- 2#edge.width
hd &lt;- paste(rep(&quot; &quot;,0), collapse=&quot;&quot;)
cm &lt;- 3
vc &lt;- &quot;orange&quot;#gray(0.8)#palette(&quot;default&quot;)#&quot;grey&quot;#vertex.color
X11(width = 18, height=6)
#par(mfrow=c(1,3))
plot(g, edge.label=paste(hd, round(E(g)$weight,1)), layout=lay, vertex.size=vs, edge.color=ec, edge.label.cex=elx, vertex.label.cex=vlc, edge.width=ew, edge.label.color=elc, vertex.color=vc)
title(&quot;(a) Weights&quot;, cex.main = cm)</code></pre>
<p><img src="/post/20160524_igraph_applications_files/figure-html/unnamed-chunk-7-1.png" width="672" /></p>
<pre class="r"><code>V(g)$name &lt;- paste(round(cnt,3))
plot(g, layout=lay, vertex.size=vs, edge.color=ec, edge.label.cex=elx, vertex.label.cex=vlc, edge.width=ew, edge.label.color=elc, vertex.color=vc)
title(&quot;(b) local closeness normalized&quot;, cex.main = cm)</code></pre>
<p><img src="/post/20160524_igraph_applications_files/figure-html/unnamed-chunk-7-2.png" width="672" /></p>
<pre class="r"><code>V(g)$name &lt;- paste(round(cnf,3))
plot(g, layout=lay, vertex.size=vs, edge.color=ec, edge.label.cex=elx, vertex.label.cex=vlc, edge.width=ew, edge.label.color=elc, vertex.color=vc)
title(&quot;(c) local closeness&quot;, cex.main = cm)</code></pre>
<p><img src="/post/20160524_igraph_applications_files/figure-html/unnamed-chunk-7-3.png" width="672" /></p>
<div id="my-solution" class="section level4">
<h4>My solution</h4>
<p>easy workaround for local centralities: define neighborhood for each node, calcualte ‘global’ centralities for these neighborhoods and normalize it individually.</p>
</div>
</div>
</div>
</div>
<div id="what-for-did-we-use-centralities" class="section level1">
<h1>What for did we use centralities?</h1>
<p>Thanks to Anita Graser for the beautiful plots!</p>
<p><span class="math display">\[\hat{y}_{t,\gamma}(s,b,c) = \beta_t + \beta_{\gamma,s} \cdot s + \beta_{\gamma,b} \cdot b + \beta_{\gamma,c} \cdot c + \beta_{\gamma,bc} \cdot b \cdot c\]</span></p>
<p>some plots:</p>
<div id="global-betweenness" class="section level2">
<h2>Global Betweenness</h2>
<p><img src="/img/20160524_igraph_applications_files/figure-markdown_strict/pic1.png" title="**Global Betweenness** \
*Global Betweenness*" alt="**Global Betweenness** \
*Global Betweenness*" style='width:100%;' border="0" /></p>
</div>
<div id="local-betweenness" class="section level2">
<h2>Local Betweenness</h2>
<p><img src="/img/20160524_igraph_applications_files/figure-markdown_strict/pic2.png" title="**Local Betweenness** \
*Local Betweenness*" alt="**Local Betweenness** \
*Local Betweenness*" style='width:100%;' border="0" /></p>
</div>
<div id="global-closeness" class="section level2">
<h2>Global Closeness</h2>
<p><img src="/img/20160524_igraph_applications_files/figure-markdown_strict/pic3.png" title="**Global Closeness** \
*Global Closeness*" alt="**Global Closeness** \
*Global Closeness*" style='width:100%;' border="0" /></p>
</div>
<div id="local-closeness" class="section level2">
<h2>Local Closeness</h2>
<p><img src="/img/20160524_igraph_applications_files/figure-markdown_strict/pic4.png" title="**Local Closeness** \
*Local Closeness*" alt="**Local Closeness** \
*Local Closeness*" style='width:100%;' border="0" /></p>
</div>
<div id="real-world-difference-of-node-based-and-link-based-betweenness-for-a-link" class="section level2">
<h2>Real world difference of node-based and link-based Betweenness for a link</h2>
<p><img src="/img/20160524_igraph_applications_files/figure-markdown_strict/pic5.png" title="**Real world difference 1** \
*Real world difference 1*" alt="**Real world difference 1** \
*Real world difference 1*" style='width:100%;' border="0" /></p>
<p><img src="/img/20160524_igraph_applications_files/figure-markdown_strict/pic6.png" title="**Real world difference 2** \
*Real world difference 2*" alt="**Real world difference 2** \
*Real world difference 2*" style='width:100%;' border="0" /></p>
</div>
<div id="improvement-travel-time-model" class="section level2">
<h2>Improvement travel time model</h2>
<div id="mape-difference-global-minus-local" class="section level3">
<h3>MAPE Difference Global minus local</h3>
<p><img src="/img/20160524_igraph_applications_files/figure-markdown_strict/pic7.png" title="**MAPE Difference** \
*MAPE Difference*" alt="**MAPE Difference** \
*MAPE Difference*" style='width:100%;' border="0" /></p>
</div>
<div id="detail-mape-base" class="section level3">
<h3>Detail MAPE base</h3>
<p><img src="/img/20160524_igraph_applications_files/figure-markdown_strict/pic8.png" title="**MAPE base** \
*MAPE base*" alt="**MAPE base** \
*MAPE base*" style='width:100%;' border="0" /></p>
</div>
<div id="detail-mape-with-local-centralities" class="section level3">
<h3>Detail MAPE with local centralities</h3>
<p><img src="/img/20160524_igraph_applications_files/figure-markdown_strict/pic9.png" title="**MAPE local** \
*MAPE local*" alt="**MAPE local** \ *MAPE local*" style='width:100%;' border="0" /></p>
</div>
</div>
</div>
</description>
</item>
<item>
<title>igraph Applications for Transportation Networks</title>
<link>/blog/2016/08/24/igraph-applications-for-transportation-networks/</link>
<pubDate>Wed, 24 Aug 2016 22:20:00 CEST</pubDate>
<author>Vienna-R</author>
<guid>/blog/2016/08/24/igraph-applications-for-transportation-networks/</guid>
<description><p>Materials from Max Leodolters talk in May covering the <strong>igraph</strong>
package.</p>
<pre><code>require(igraph)
require(data.table)
require(ggplot2)
</code></pre>
<ul>
<li><a href="#centrality---what-is-it">Centrality - What is it?</a></li>
<li><a href="#igraph-for-centralities">igraph for centralities</a>
<ul>
<li><a href="#node-betweenness">Node Betweenness</a></li>
<li><a href="#local-vs.-global">Local vs. Global</a></li>
<li><a href="#node-based-vs.-link-based-betweenness-for-links">Node-based vs. link-based Betweenness for
Links</a></li>
<li><a href="#bugsfeaturesspecial-experiences">Bugs/Features/Special
experiences</a></li>
</ul></li>
<li><a href="#what-for-did-we-use-centralities">What for did we use
centralities?</a>
<ul>
<li><a href="#global-betweenness">Global Betweenness</a></li>
<li><a href="#local-betweenness">Local Betweenness</a></li>
<li><a href="#global-closeness">Global Closeness</a></li>
<li><a href="#local-closeness">Local Closeness</a></li>
<li><a href="#real-world-difference-of-node-based-and-link-based-betweenness-for-a-link">Real world difference of node-based and link-based Betweenness
for a
link</a></li>
<li><a href="#improvement-travel-time-model">Improvement travel time model</a></li>
</ul></li>
</ul>
<h1 id="centrality-what-is-it">Centrality - What is it?</h1>
<p>Network Centrality gives you an idea of how important a vertex/node and
edge/link in your network/graph <em>N</em>(<em>V</em>, <em>E</em>) respectively <em>G</em>(<em>N</em>, <em>L</em>)
is. Examples:</p>
<ul>
<li>Closeness</li>
<li>Betweenness</li>
<li>Eigenvalue</li>
<li>degree</li>
<li>&hellip;</li>
</ul>
<p>Some formulas:</p>
<ul>
<li>Closeness Centrality
$$ C^{node}(n) = \frac{1}{\sum_{m \in N \setminus \{n\}}d(n,m)} $$</li>
<li>Betweenness centrality
$$ B^{node}(n) = \sum_{m\neq o \in N\backslash \{n\} } \frac{\sigma_{mo}(n)}{\sigma_{mo}} $$</li>
<li>Node-based Closeness for a link
$$ \ddot{C}^{link}(l_{n,m}) = \frac{C^{node}(n) + C^{node}(m)}{2} $$</li>
<li>Node-based Betweenness for a link
$$ \ddot{B}^{link}(l_{n,m}) = \frac{B^{node}(n) + B^{node}(m)}{2} $$</li>
<li>Link-based Betweenness for a link
$$ B^{link}(l) = \sum_{n \neq m \in N } \frac{\sigma_{nm}(l)}{\sigma_{nm}} $$
*<em>σ</em> is the number of traversing OD relations, and <em>d</em>(<em>n</em>, <em>m</em>)
is the distance of the shortest route from <em>n</em> to <em>m</em></li>
</ul>
<p>What to select, $\ddot{B}^{link}(l_{n,m})$ or $ B^{link}(l)$?</p>
<h1 id="igraph-for-centralities">igraph for centralities</h1>
<h2 id="node-betweenness">Node Betweenness</h2>
<pre><code>g &lt;- make_star(5, mode = &quot;undirected&quot;, center=3)
V(g)$name &lt;- letters[1:length(V(g))]
plot(g)
</code></pre>
<p><img src="/img/20160524_igraph_applications_files/figure-markdown_strict/unnamed-chunk-2-1.png" alt="" /></p>
<pre><code>g &lt;- set.edge.attribute(g, &quot;weight&quot;, value= 1)
b &lt;- betweenness(g, directed=F)
V(g)$name &lt;- b
plot(g)
</code></pre>
<p><img src="/img/20160524_igraph_applications_files/figure-markdown_strict/unnamed-chunk-2-2.png" alt="" /></p>
<p>Edge Betweenness:</p>
<pre><code>g &lt;- make_star(5, mode = &quot;undirected&quot;, center=3)
V(g)$name &lt;- letters[1:length(V(g))]
g &lt;- set.edge.attribute(g, &quot;weight&quot;, value= 1)
bg &lt;- edge_betweenness(g, directed=F)
plot(g, edge.label = bg)
</code></pre>
<p><img src="/img/20160524_igraph_applications_files/figure-markdown_strict/unnamed-chunk-3-1.png" alt="" /></p>
<h2 id="local-vs-global">Local vs. Global</h2>
<pre><code>g &lt;- make_graph(c(1, 2, 2, 3,#horizontal connections
4,5,5,6,6,7,
1,6,#vertical connections
2,7), directed = FALSE)
#g &lt;- make_star(10, mode = &quot;undirected&quot;, center=3)
V(g)$name &lt;- letters[1:length(V(g))]
g &lt;- set.edge.attribute(g, &quot;weight&quot;, value= 1)
set.seed(2)
lay &lt;- layout.auto(g)
bl &lt;- estimate_edge_betweenness(g, cutoff = 1.5, directed=F);bl
## [1] 3 3 2 4 3 3 3
bg &lt;- edge_betweenness(g, directed=F)
# set plotting parameters
vs &lt;- 15# vertex.size
ec &lt;- gray(0.8)#edge.color
elx &lt;- 2# edge.label.cex
elc &lt;- &quot;black&quot;#,edge.label.color
vlc &lt;- 2#vertex.label.cex
ew &lt;- 2#edge.width
hd &lt;- paste(rep(&quot; &quot;,0), collapse=&quot;&quot;)
cm &lt;- 3
vc &lt;- &quot;orange&quot;#gray(0.8)#palette(&quot;default&quot;)#&quot;grey&quot;#vertex.color
#windows(width = 18, height=6)
#par(mfrow=c(1,3))
plot(g, edge.label=paste(hd, round(E(g)$weight,1)), layout=lay, vertex.size=vs, edge.color=ec, edge.label.cex=elx, vertex.label.cex=vlc, edge.width=ew, edge.label.color=elc, vertex.color=vc)
title(&quot;(a) Weights&quot;, cex.main = cm)
</code></pre>
<p><img src="/img/20160524_igraph_applications_files/figure-markdown_strict/unnamed-chunk-4-1.png" alt="" /></p>
<pre><code>plot(g, edge.label=paste(hd, round(bl,1)), layout=lay, vertex.size=vs, edge.color=ec, edge.label.cex=elx, vertex.label.cex=vlc, edge.width=ew, edge.label.color=elc, vertex.color=vc)
title(&quot;(b) Local Betweenness&quot;, cex.main = cm)
</code></pre>
<p><img src="/img/20160524_igraph_applications_files/figure-markdown_strict/unnamed-chunk-4-2.png" alt="" /></p>
<pre><code>plot(g, edge.label=paste(hd, round(bg,1)), layout=lay, vertex.size=vs, edge.color=ec, edge.label.cex=elx, vertex.label.cex=vlc, edge.width=ew, edge.label.color=elc, vertex.color=vc)
title(&quot;(c) Global Betweenness&quot;, cex.main = cm)
</code></pre>
<p><img src="/img/20160524_igraph_applications_files/figure-markdown_strict/unnamed-chunk-4-3.png" alt="" /></p>
<h2 id="node-based-vs-link-based-betweenness-for-links">Node-based vs. link-based Betweenness for Links</h2>
<pre><code>g &lt;- make_graph(c(1,2, 2,3, 3,4, 4,5,#horizontal connections
6,7, 7,8, 8,9, 9,10,
2,7,#vertical connections
3,8,
4,9), directed = FALSE)
V(g)$name &lt;- letters[1:length(V(g))]
set.seed(1210)
g &lt;- set.edge.attribute(g, &quot;weight&quot;, value= 1)
g &lt;- set.edge.attribute(g, &quot;weight&quot;, index= c(10), value= 2)
#plot(g,edge.label=paste(hd, round(E(g)$weight,1)))
lay &lt;- layout.auto(g)
eb &lt;- edge_betweenness(g, directed=F)
vb &lt;- betweenness(g, directed=F)
tmp1 &lt;- as.data.table(as.data.frame(cbind(get.edgelist(g))))
tmp1[,id:=1:.N]
tmp2 &lt;- as.data.table(data.frame(value=vb, name=names(vb)))
setnames(tmp1, &quot;V1&quot;, &quot;name&quot;)
tmp3 &lt;- merge(tmp1, tmp2, by =&quot;name&quot;)
setnames(tmp3, &quot;name&quot;, &quot;V1&quot;)
setnames(tmp3, &quot;V2&quot;, &quot;name&quot;)
tmp4 &lt;- merge(tmp3, tmp2, by =&quot;name&quot;)
setnames(tmp4, &quot;name&quot;, &quot;V2&quot;)
tmp4[,m:=mean(c(value.x, value.y)) , by=c(&quot;V2&quot;,&quot;V1&quot;)]
evb &lt;- tmp4[order(id),list(V1,V2,m)]$m
# set plotting parameters
vs &lt;- 15# vertex.size
ec &lt;- &quot;grey&quot;#edge.color
elx &lt;- 2# edge.label.cex
elc &lt;- &quot;black&quot;#edge.label.color
vlc &lt;- 2#vertex.label.cex
ew &lt;- 2#edge.width
hd &lt;- paste(rep(&quot; &quot;,0), collapse=&quot;&quot;)
cm &lt;- 3
vc &lt;- &quot;orange&quot;# vertex.color
windows(width = 18, height=6)
#par(mfrow=c(1,3))
plot(g, edge.label=paste(hd, round(E(g)$weight,1)), layout=lay, vertex.size=vs, edge.color=ec, edge.label.cex=elx, vertex.label.cex=vlc, edge.width=ew, edge.label.color=elc, vertex.color=vc)
title(&quot;(a) Weights&quot;,cex.main=cm)
</code></pre>
<p><img src="/img/20160524_igraph_applications_files/figure-markdown_strict/unnamed-chunk-5-1.png" alt="" /></p>
<pre><code>plot(g, edge.label=paste(hd, round(eb,1)), layout=lay, vertex.size=vs, edge.color=ec, edge.label.cex=elx, vertex.label.cex=vlc, edge.width=ew, edge.label.color=elc, vertex.color=vc)
title(&quot;(b) Link based Betweenness&quot;,cex.main=cm)
</code></pre>
<p><img src="/img/20160524_igraph_applications_files/figure-markdown_strict/unnamed-chunk-5-2.png" alt="" /></p>
<pre><code>V(g)$name &lt;- paste(vb)
plot(g, edge.label=paste(hd, round(evb,1)), layout=lay, vertex.size=vs, edge.color=ec, edge.label.cex=elx, vertex.label.cex=vlc, edge.width=ew, edge.label.color=elc, vertex.color=vc)
title(&quot;(c) Node based Betweenness&quot; ,cex.main=cm)
</code></pre>
<p><img src="/img/20160524_igraph_applications_files/figure-markdown_strict/unnamed-chunk-5-3.png" alt="" /></p>
<h2 id="bugs-features-special-experiences">Bugs/Features/Special experiences</h2>
<ul>
<li>demonstrate the parameter &lsquo;lay&rsquo; with setting it NULL</li>
<li>cutoff parameter</li>
<li>nodes need to be named for using induced.subgraph(), otherwise
problems in matching results</li>
</ul>
<h3 id="cutoff">cutoff</h3>
<p>stackoverflow:
<a href="http://stackoverflow.com/questions/34180036/how-does-the-cutoff-parameter-influence-betweenness-calculation">http://stackoverflow.com/questions/34180036/how-does-the-cutoff-parameter-influence-betweenness-calculation</a></p>
<p>discussion:
<a href="https://lists.nongnu.org/archive/html/igraph-help/2012-11/msg00083.html">https://lists.nongnu.org/archive/html/igraph-help/2012-11/msg00083.html</a></p>
<p>github project:
<a href="https://github.com/maxar/igraph_testing/blob/master/test_vertex_betweenness_local.R">https://github.com/maxar/igraph_testing/blob/master/test_vertex_betweenness_local.R</a></p>
<pre><code>require(igraph)
packageVersion(&quot;igraph&quot;) # my installed version is 1.0.1
## [1] '1.0.1'
#----------------------------------------------------------------------------------------
#--------------- EXAMPLE 1 --------------------------------------------------------
#----------------------------------------------------------------------------------------
#--- set plotting parameters
vs &lt;- 25# vertex.size
ec &lt;- gray(0.8)#edge.color
elx &lt;- 2# edge.label.cex
elc &lt;- &quot;black&quot;#,edge.label.color
vlc &lt;- 2#vertex.label.cex
ew &lt;- 2#edge.width
cm &lt;- 2
vc &lt;- &quot;orange&quot;
g &lt;- make_graph(c(1, 2, 2, 3, 3, 4, 4,5, 5, 6, 6, 7) , directed = FALSE)
set.seed(1210)
lay &lt;- layout.auto(g)
graphics.off()
windows(width = 30, height=10)
#par(mfrow=c(1,3))
V(g)$name &lt;- letters[1:length(V(g))]
g &lt;- set.edge.attribute(g, &quot;weight&quot;, value= c(2,3,5,5,3,2))
plot(g, edge.label=round(E(g)$weight,1), layout=lay, vertex.size=vs, edge.color=ec, edge.label.cex=elx, vertex.label.cex=vlc, edge.width=ew, edge.label.color=elc, vertex.color=vc)
title(&quot;(a) Weights&quot;, cex.main = cm)
</code></pre>
<p><img src="/img/20160524_igraph_applications_files/figure-markdown_strict/unnamed-chunk-6-1.png" alt="" /></p>
<pre><code>bl.1 &lt;- estimate_betweenness(g, cutoff=10)
V(g)$name &lt;- bl.1
plot(g, layout=lay, vertex.size=vs, edge.color=ec, edge.label.cex=elx, vertex.label.cex=vlc, edge.width=ew, edge.label.color=elc, vertex.color=vc)
title(&quot;(b) Local Betweenness\ncutoff 10&quot;, cex.main = cm)
</code></pre>
<p><img src="/img/20160524_igraph_applications_files/figure-markdown_strict/unnamed-chunk-6-2.png" alt="" /></p>
<pre><code>bl.2 &lt;- estimate_betweenness(g, cutoff=Inf)
V(g)$name &lt;- bl.2
plot(g, layout=lay, vertex.size=vs, edge.color=ec, edge.label.cex=elx, vertex.label.cex=vlc, edge.width=ew, edge.label.color=elc, vertex.color=vc)
title(&quot;(b) Global Betweenness\ncutoff Inf&quot;, cex.main = cm)
</code></pre>
<p><img src="/img/20160524_igraph_applications_files/figure-markdown_strict/unnamed-chunk-6-3.png" alt="" /></p>
<pre><code># Comments and Discussion:
# This simple example illustrates, why it is questionable
# that the cutoff parameter actually measures distance independent of the edge weights
#
# 1. define edge weights as in plot (a)
# 2. calculate vertex betweenness with cutoff 10 (b)
# 3. calculate vertex betweenness with cutoff Inf (c)
#----------------------------------------------------------------------------------------
#--------------- EXAMPLE 2 --------------------------------------------------------
#----------------------------------------------------------------------------------------
#--- set plotting parameters
vs &lt;- 25# vertex.size
ec &lt;- gray(0.8)#edge.color
elx &lt;- 2# edge.label.cex
elc &lt;- &quot;black&quot;#,edge.label.color
vlc &lt;- 2#vertex.label.cex
ew &lt;- 2#edge.width
cm &lt;- 2
vc &lt;- &quot;orange&quot;