Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: netrics
Title: Many Ways to Measure and Classify Membership for Networks, Nodes, and Ties
Version: 0.2.1
Date: 2026-04-04
Version: 0.2.2
Date: 2026-04-24
Description: Many tools for calculating network, node, or tie
marks, measures, motifs and memberships of many different types of networks.
Marks identify structural positions, measures quantify network properties,
Expand Down
13 changes: 13 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# netrics 0.2.2

## Package

- Updated logos

## Tutorials

- Updated centrality tutorial
- Updated community tutorial
- Updated position tutorial
- Updated topology tutorial

# netrics 0.2.1

## Package
Expand Down
Binary file added inst/netrics.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
76 changes: 38 additions & 38 deletions inst/tutorials/tutorial3/centrality.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@
"Ça a l'air facile!",
"C'était un travail de première classe.",
"C'est ce que j'appelle un bon travail!"),
encouragement = c("Bon effort",

Check warning on line 35 in inst/tutorials/tutorial3/centrality.Rmd

View workflow job for this annotation

GitHub Actions / Build for ubuntu-latest

file=inst/tutorials/tutorial3/centrality.Rmd,line=35,col=26,[indentation_linter] Hanging indent should be 27 spaces but is 26 spaces.

Check warning on line 35 in inst/tutorials/tutorial3/centrality.Rmd

View workflow job for this annotation

GitHub Actions / Build for windows-latest

file=inst/tutorials/tutorial3/centrality.Rmd,line=35,col=26,[indentation_linter] Hanging indent should be 27 spaces but is 26 spaces.

Check warning on line 35 in inst/tutorials/tutorial3/centrality.Rmd

View workflow job for this annotation

GitHub Actions / Build for macOS-latest

file=inst/tutorials/tutorial3/centrality.Rmd,line=35,col=26,[indentation_linter] Hanging indent should be 27 spaces but is 26 spaces.
"Vous l'avez presque maîtrisé!",
"Ça avance bien.",
"Continuez comme ça.",
"Continuez à travailler dur!",
"Vous apprenez vite!",
"Vous faites un excellent travail aujourd'hui."))

Check warning on line 41 in inst/tutorials/tutorial3/centrality.Rmd

View workflow job for this annotation

GitHub Actions / Build for ubuntu-latest

file=inst/tutorials/tutorial3/centrality.Rmd,line=41,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 93 characters.

Check warning on line 41 in inst/tutorials/tutorial3/centrality.Rmd

View workflow job for this annotation

GitHub Actions / Build for windows-latest

file=inst/tutorials/tutorial3/centrality.Rmd,line=41,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 93 characters.

Check warning on line 41 in inst/tutorials/tutorial3/centrality.Rmd

View workflow job for this annotation

GitHub Actions / Build for macOS-latest

file=inst/tutorials/tutorial3/centrality.Rmd,line=41,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 93 characters.
learnr::random_phrases_add(language = "en",

Check warning on line 42 in inst/tutorials/tutorial3/centrality.Rmd

View workflow job for this annotation

GitHub Actions / Build for ubuntu-latest

file=inst/tutorials/tutorial3/centrality.Rmd,line=42,col=44,[trailing_whitespace_linter] Remove trailing whitespace.

Check warning on line 42 in inst/tutorials/tutorial3/centrality.Rmd

View workflow job for this annotation

GitHub Actions / Build for windows-latest

file=inst/tutorials/tutorial3/centrality.Rmd,line=42,col=44,[trailing_whitespace_linter] Remove trailing whitespace.

Check warning on line 42 in inst/tutorials/tutorial3/centrality.Rmd

View workflow job for this annotation

GitHub Actions / Build for macOS-latest

file=inst/tutorials/tutorial3/centrality.Rmd,line=42,col=44,[trailing_whitespace_linter] Remove trailing whitespace.
praise = c("C'est génial!",
"Beau travail!",
"Bravo!",
"Super!"),
encouragement = c("Bon effort"))
ison_brandes2 <- ison_brandes %>% rename(type = twomode_type)

Check warning on line 48 in inst/tutorials/tutorial3/centrality.Rmd

View workflow job for this annotation

GitHub Actions / Build for ubuntu-latest

file=inst/tutorials/tutorial3/centrality.Rmd,line=48,col=31,[pipe_consistency_linter] Use the |> pipe operator instead of the %>% pipe operator.

Check warning on line 48 in inst/tutorials/tutorial3/centrality.Rmd

View workflow job for this annotation

GitHub Actions / Build for windows-latest

file=inst/tutorials/tutorial3/centrality.Rmd,line=48,col=31,[pipe_consistency_linter] Use the |> pipe operator instead of the %>% pipe operator.

Check warning on line 48 in inst/tutorials/tutorial3/centrality.Rmd

View workflow job for this annotation

GitHub Actions / Build for macOS-latest

file=inst/tutorials/tutorial3/centrality.Rmd,line=48,col=31,[pipe_consistency_linter] Use the |> pipe operator instead of the %>% pipe operator.
```

## Today's target
Expand All @@ -72,7 +72,7 @@

```{r coercion-hint-1, purl = FALSE}
# Let's graph the one-mode version
graphr(____)

Check warning on line 75 in inst/tutorials/tutorial3/centrality.Rmd

View workflow job for this annotation

GitHub Actions / Build for ubuntu-latest

file=inst/tutorials/tutorial3/centrality.Rmd,line=75,col=9,[error] unexpected input

Check warning on line 75 in inst/tutorials/tutorial3/centrality.Rmd

View workflow job for this annotation

GitHub Actions / Build for windows-latest

file=inst/tutorials/tutorial3/centrality.Rmd,line=75,col=9,[error] unexpected input

Check warning on line 75 in inst/tutorials/tutorial3/centrality.Rmd

View workflow job for this annotation

GitHub Actions / Build for macOS-latest

file=inst/tutorials/tutorial3/centrality.Rmd,line=75,col=9,[error] unexpected input
```

```{r coercion-hint-2, purl = FALSE}
Expand Down Expand Up @@ -134,7 +134,7 @@

```{r degreesum-hint-2, purl = FALSE}
# Or by using a built in command in manynet like this:
node_degree(ison_brandes, normalized = FALSE)
node_by_degree(ison_brandes, normalized = FALSE)
```

```{r degreesum-solution}
Expand All @@ -143,22 +143,22 @@
degrees <- rowSums(mat)
rowSums(mat) == colSums(mat)
# You can also just use a built in command in manynet though:
node_degree(ison_brandes, normalized = FALSE)
node_by_degree(ison_brandes, normalized = FALSE)
```

```{r degreesum-Q, echo=FALSE, purl = FALSE}
question("Are the row sums the same as the column sums?",
answer("Yes",

Check warning on line 151 in inst/tutorials/tutorial3/centrality.Rmd

View workflow job for this annotation

GitHub Actions / Build for ubuntu-latest

file=inst/tutorials/tutorial3/centrality.Rmd,line=151,col=2,[indentation_linter] Indentation should be 0 spaces but is 2 spaces.

Check warning on line 151 in inst/tutorials/tutorial3/centrality.Rmd

View workflow job for this annotation

GitHub Actions / Build for windows-latest

file=inst/tutorials/tutorial3/centrality.Rmd,line=151,col=2,[indentation_linter] Indentation should be 0 spaces but is 2 spaces.

Check warning on line 151 in inst/tutorials/tutorial3/centrality.Rmd

View workflow job for this annotation

GitHub Actions / Build for macOS-latest

file=inst/tutorials/tutorial3/centrality.Rmd,line=151,col=2,[indentation_linter] Indentation should be 0 spaces but is 2 spaces.
correct = TRUE,

Check warning on line 152 in inst/tutorials/tutorial3/centrality.Rmd

View workflow job for this annotation

GitHub Actions / Build for ubuntu-latest

file=inst/tutorials/tutorial3/centrality.Rmd,line=152,col=9,[indentation_linter] Indentation should be 0 spaces but is 9 spaces.

Check warning on line 152 in inst/tutorials/tutorial3/centrality.Rmd

View workflow job for this annotation

GitHub Actions / Build for windows-latest

file=inst/tutorials/tutorial3/centrality.Rmd,line=152,col=9,[indentation_linter] Indentation should be 0 spaces but is 9 spaces.

Check warning on line 152 in inst/tutorials/tutorial3/centrality.Rmd

View workflow job for this annotation

GitHub Actions / Build for macOS-latest

file=inst/tutorials/tutorial3/centrality.Rmd,line=152,col=9,[indentation_linter] Indentation should be 0 spaces but is 9 spaces.
message = "That's right, that's because this is an undirected network."),

Check warning on line 153 in inst/tutorials/tutorial3/centrality.Rmd

View workflow job for this annotation

GitHub Actions / Build for ubuntu-latest

file=inst/tutorials/tutorial3/centrality.Rmd,line=153,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 82 characters.

Check warning on line 153 in inst/tutorials/tutorial3/centrality.Rmd

View workflow job for this annotation

GitHub Actions / Build for windows-latest

file=inst/tutorials/tutorial3/centrality.Rmd,line=153,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 82 characters.

Check warning on line 153 in inst/tutorials/tutorial3/centrality.Rmd

View workflow job for this annotation

GitHub Actions / Build for macOS-latest

file=inst/tutorials/tutorial3/centrality.Rmd,line=153,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 82 characters.
answer("No"),

Check warning on line 154 in inst/tutorials/tutorial3/centrality.Rmd

View workflow job for this annotation

GitHub Actions / Build for ubuntu-latest

file=inst/tutorials/tutorial3/centrality.Rmd,line=154,col=2,[indentation_linter] Indentation should be 0 spaces but is 2 spaces.

Check warning on line 154 in inst/tutorials/tutorial3/centrality.Rmd

View workflow job for this annotation

GitHub Actions / Build for windows-latest

file=inst/tutorials/tutorial3/centrality.Rmd,line=154,col=2,[indentation_linter] Indentation should be 0 spaces but is 2 spaces.

Check warning on line 154 in inst/tutorials/tutorial3/centrality.Rmd

View workflow job for this annotation

GitHub Actions / Build for macOS-latest

file=inst/tutorials/tutorial3/centrality.Rmd,line=154,col=2,[indentation_linter] Indentation should be 0 spaces but is 2 spaces.
allow_retry = FALSE
)
```

```{r degreeinterpQ, purl = FALSE}
question("In what ways are higher degree nodes more 'central'?",
answer("They have more power than other nodes",

Check warning on line 161 in inst/tutorials/tutorial3/centrality.Rmd

View workflow job for this annotation

GitHub Actions / Build for ubuntu-latest

file=inst/tutorials/tutorial3/centrality.Rmd,line=161,col=9,[indentation_linter] Indentation should be 0 spaces but is 9 spaces.

Check warning on line 161 in inst/tutorials/tutorial3/centrality.Rmd

View workflow job for this annotation

GitHub Actions / Build for windows-latest

file=inst/tutorials/tutorial3/centrality.Rmd,line=161,col=9,[indentation_linter] Indentation should be 0 spaces but is 9 spaces.

Check warning on line 161 in inst/tutorials/tutorial3/centrality.Rmd

View workflow job for this annotation

GitHub Actions / Build for macOS-latest

file=inst/tutorials/tutorial3/centrality.Rmd,line=161,col=9,[indentation_linter] Indentation should be 0 spaces but is 9 spaces.
message = "Not necessarily"),
answer("They are more active than other nodes",
correct = TRUE, message = learnr::random_praise()),
Expand All @@ -184,7 +184,7 @@

```{r distrib-solution}
# distribution of degree centrality scores of nodes
plot(node_degree(ison_brandes))
plot(node_by_degree(ison_brandes))
```

What's plotted here by default is both the degree distribution as a histogram,
Expand Down Expand Up @@ -218,7 +218,7 @@
## Other centralities

Other measures of centrality can be a little trickier to calculate by hand.
Fortunately, we can use functions from `{manynet}` to help calculate the
Fortunately, we can use functions from `{netrics}` to help calculate the
`r gloss("betweenness")`, `r gloss("closeness")`, and `r gloss("eigenvector")` centralities for each node in the network.
Let's collect the vectors of these centralities for the `ison_brandes` dataset:
Comment on lines +221 to 223

Expand All @@ -227,27 +227,27 @@
```

```{r micent-hint-1, purl = FALSE}
# Use the node_betweenness() function to calculate the
# Use the node_by_betweenness() function to calculate the
# betweenness centralities of nodes in a network
node_betweenness(ison_brandes)
node_by_betweenness(ison_brandes)
```

```{r micent-hint-2, purl = FALSE}
# Use the node_closeness() function to calculate the
# Use the node_by_closeness() function to calculate the
# closeness centrality of nodes in a network
node_closeness(ison_brandes)
node_by_closeness(ison_brandes)
```

```{r micent-hint-3, purl = FALSE}
# Use the node_eigenvector() function to calculate
# Use the node_by_eigenvector() function to calculate
# the eigenvector centrality of nodes in a network
node_eigenvector(ison_brandes)
node_by_eigenvector(ison_brandes)
```

```{r micent-solution}
node_betweenness(ison_brandes)
node_closeness(ison_brandes)
node_eigenvector(ison_brandes)
node_by_betweenness(ison_brandes)
node_by_closeness(ison_brandes)
node_by_eigenvector(ison_brandes)
```

What is returned here are vectors of betweenness, closeness, and eigenvector
Expand Down Expand Up @@ -301,7 +301,7 @@
- what does Bonacich mean when he says that `r gloss("power")` and influence are not the same thing?
- can you think of a real-world example when an actor might be central but not powerful, or powerful but not central?

Note that all centrality measures in `{manynet}` return normalized
Note that all centrality measures in `{netrics}` return normalized
scores by default --
for the raw scores, include `normalized = FALSE` in the function as an extra argument.

Expand All @@ -312,9 +312,9 @@
```

```{r otherdist-solution}
plot(node_betweenness(ison_brandes))
plot(node_closeness(ison_brandes))
plot(node_eigenvector(ison_brandes))
plot(node_by_betweenness(ison_brandes))
plot(node_by_closeness(ison_brandes))
plot(node_by_eigenvector(ison_brandes))
```

## Plotting centrality
Expand All @@ -335,19 +335,19 @@
```{r ggid-solution}
# plot the network, highlighting the node with the highest centrality score with a different colour
ison_brandes %>%
mutate_nodes(color = node_is_max(node_degree())) %>%
mutate_nodes(color = node_is_max(node_by_degree())) %>%
graphr(node_color = "color")
Comment on lines 337 to 339

ison_brandes %>%
mutate_nodes(color = node_is_max(node_betweenness())) %>%
mutate_nodes(color = node_is_max(node_by_betweenness())) %>%
graphr(node_color = "color")
Comment on lines 341 to 343

ison_brandes %>%
mutate_nodes(color = node_is_max(node_closeness())) %>%
mutate_nodes(color = node_is_max(node_by_closeness())) %>%
graphr(node_color = "color")
Comment on lines 345 to 347

ison_brandes %>%
mutate_nodes(color = node_is_max(node_eigenvector())) %>%
mutate_nodes(color = node_is_max(node_by_eigenvector())) %>%
graphr(node_color = "color")
```

Expand All @@ -361,19 +361,19 @@

```{r ggid_twomode-solution}
ison_brandes2 %>%
add_node_attribute("color", node_is_max(node_degree(ison_brandes2))) %>%
add_node_attribute("color", node_is_max(node_by_degree(ison_brandes2))) %>%
graphr(node_color = "color", layout = "bipartite")

ison_brandes2 %>%
add_node_attribute("color", node_is_max(node_betweenness(ison_brandes2))) %>%
add_node_attribute("color", node_is_max(node_by_betweenness(ison_brandes2))) %>%
graphr(node_color = "color", layout = "bipartite")

ison_brandes2 %>%
add_node_attribute("color", node_is_max(node_closeness(ison_brandes2))) %>%
add_node_attribute("color", node_is_max(node_by_closeness(ison_brandes2))) %>%
graphr(node_color = "color", layout = "bipartite")

ison_brandes2 %>%
add_node_attribute("color", node_is_max(node_eigenvector(ison_brandes2))) %>%
add_node_attribute("color", node_is_max(node_by_eigenvector(ison_brandes2))) %>%
graphr(node_color = "color", layout = "bipartite")
```

Expand All @@ -391,7 +391,7 @@

<img src="https://media.makeameme.org/created/centralization-here-i.jpg"/>

`{manynet}` also implements network `r gloss("centralization")` functions.
`{netrics}` also implements network `r gloss("centralization")` functions.
Here we are no longer interested in the level of the node,
but in the level of the whole network,
so the syntax replaces `node_` with `net_`:
Expand All @@ -401,10 +401,10 @@
```

```{r centzn-solution}
net_degree(ison_brandes)
net_betweenness(ison_brandes)
net_closeness(ison_brandes)
print(net_eigenvector(ison_brandes), digits = 5)
net_by_degree(ison_brandes)
net_by_betweenness(ison_brandes)
net_by_closeness(ison_brandes)
print(net_by_eigenvector(ison_brandes), digits = 5)
```

By default, scores are printed up to 3 decimal places,
Expand All @@ -428,18 +428,18 @@

```{r multiplot-solution}
ison_brandes <- ison_brandes %>%
add_node_attribute("degree", node_is_max(node_degree(ison_brandes))) %>%
add_node_attribute("betweenness", node_is_max(node_betweenness(ison_brandes))) %>%
add_node_attribute("closeness", node_is_max(node_closeness(ison_brandes))) %>%
add_node_attribute("eigenvector", node_is_max(node_eigenvector(ison_brandes)))
add_node_attribute("degree", node_is_max(node_by_degree(ison_brandes))) %>%
add_node_attribute("betweenness", node_is_max(node_by_betweenness(ison_brandes))) %>%
add_node_attribute("closeness", node_is_max(node_by_closeness(ison_brandes))) %>%
add_node_attribute("eigenvector", node_is_max(node_by_eigenvector(ison_brandes)))
gd <- graphr(ison_brandes, node_color = "degree") +
ggtitle("Degree", subtitle = round(net_degree(ison_brandes), 2))
ggtitle("Degree", subtitle = round(net_by_degree(ison_brandes), 2))
gc <- graphr(ison_brandes, node_color = "closeness") +
ggtitle("Closeness", subtitle = round(net_closeness(ison_brandes), 2))
ggtitle("Closeness", subtitle = round(net_by_closeness(ison_brandes), 2))
gb <- graphr(ison_brandes, node_color = "betweenness") +
ggtitle("Betweenness", subtitle = round(net_betweenness(ison_brandes), 2))
ggtitle("Betweenness", subtitle = round(net_by_betweenness(ison_brandes), 2))
ge <- graphr(ison_brandes, node_color = "eigenvector") +
ggtitle("Eigenvector", subtitle = round(net_eigenvector(ison_brandes), 2))
ggtitle("Eigenvector", subtitle = round(net_by_eigenvector(ison_brandes), 2))
(gd | gb) / (gc | ge)
# ggsave("brandes-centralities.pdf")
```
Expand Down
Loading
Loading