-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11.R
More file actions
39 lines (34 loc) · 773 Bytes
/
11.R
File metadata and controls
39 lines (34 loc) · 773 Bytes
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
library(readr)
library(purrr)
library(stringr)
library(dplyr)
library(igraph)
library(tidyr)
library(data.table)
library(dtplyr)
library(mirai)
input <- read_lines(file = "data/11.txt")
netdf <- tibble()
net <- input |>
map(\(x) {
parts <- x |> str_split_1(":")
parts[2] |>
map(\(y) {
outputs <- y |>
str_trim() |>
str_split_1(" ") |>
map(\(z) {
list(parts[1], z)
})
})
}) |>
flatten() |>
flatten() |>
map(\(x) {
netdf <<- rbind(netdf, x)
})
names(netdf) <- c("from", "to")
netobj <- graph_from_data_frame(netdf)
paths <- netobj |> all_shortest_paths("you", "out")
print(paths$epaths |> length())
paths <- netobj|> all_shortest_paths(from="fft", to="dac") # 160944 too low