File: cohesive.R

package info (click to toggle)
r-cran-igraph 1.0.1-1%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 18,232 kB
  • sloc: ansic: 173,538; cpp: 19,365; fortran: 4,550; yacc: 1,164; tcl: 931; lex: 484; makefile: 149; sh: 9
file content (57 lines) | stat: -rw-r--r-- 947 bytes parent folder | download | duplicates (5)
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

pause <- function() {}

### The Zachary Karate club network

karate <- make_graph("Zachary")
summary(karate)

pause()

### Create a layout that is used from now on

karate$layout <- layout_nicely(karate)
plot(karate)

pause()

### Run cohesive blocking on it

cbKarate <- cohesive_blocks(karate)
cbKarate

pause()

### Plot the results and all the groups

plot(cbKarate, karate)

pause()

### This is a bit messy, plot them step-by-step
### See the hierarchy tree first

hierarchy(cbKarate)
plot_hierarchy(cbKarate)

## Plot the first level, blocks 1 & 2

plot(cbKarate, karate, mark.groups=blocks(cbKarate)[1:2+1],
     col="cyan")

pause()

### The second group is simple, plot its more cohesive subgroup

plot(cbKarate, karate, mark.groups=blocks(cbKarate)[c(2,5)+1], col="cyan")

pause()

### The first group has more subgroups, plot them

sub1 <- blocks(cbKarate)[parent(cbKarate)==1]
sub1
plot(cbKarate, karate, mark.groups=sub1)

pause()