-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
63 lines (47 loc) · 1.88 KB
/
README.Rmd
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
---
title: "Make Reduced From Partition"
author: "Steven Wolf"
date: "`r Sys.Date()`"
output: github_document
---
## Setup for the new function `make_reduced_from_partition`
Load all libraries and load the new function
```{r}
library(concorR)
library(igraph)
library(viridis)
#source('mrfp.R')
```
This function ~~will be~~ has been added to the `concorR` repository on my fork ~~in the next few days~~. The Travis status is:
<!-- badges: start -->
[![Travis build status](https://travis-ci.com/sfwolfphys/concorR.svg?branch=main)](https://travis-ci.com/sfwolfphys/concorR)
<!-- badges: end -->
## Proof of concept
Note: given the fact that we have an existing network/partition, I decided to make the input be a single adjacency matrix/partition rather than a list of adjacency matricies/partitions. We want to have the list input for the other method because concor uses list inputs. However, it is superfluous here.
I messed with `edge_betweenness` to find communities in the examples in the standard README for `concorR`. They were not instructive (only one community), so I abandoned that. Instead, I have created a random network and found communities there:
```{r}
set.seed(1234)
g <- erdos.renyi.game(50,p=0.2)
g_adj <- as.matrix(as_adjacency_matrix(g))
ebc.g <- edge.betweenness.community(g)
ebPart <- ebc.g$membership
```
Show the whole network:
```{r}
vColor = viridis(max(unlist(ebPart)))
plot(g, vertex.color = vColor[ebc.g$membership])
```
First, let's show that the reduced network works for the degree statistic:
```{r}
g.red <- make_reduced_from_partition(g_adj, ebPart, stat='degree')
plot_reduced(make_reduced_igraph(g.red$reduced_mat))
```
And now, the density statistic:
```{r}
g.red.den <- make_reduced_from_partition(g_adj, ebPart, stat='density')
plot_reduced(make_reduced_igraph(g.red.den$reduced_mat))
```
## Full function text
```{r}
make_reduced_from_partition
```