Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Align the body of graph.lattice() with its replacement make_lattice() #1439

Merged
merged 1 commit into from
Aug 13, 2024

Conversation

maelle
Copy link
Contributor

@maelle maelle commented Jul 19, 2024

This is the fix for BCT, at least it fixes the reprex 😁

I'm a bit worried about these functions we inlined, looking forward to deprecating the old versions for good so we don't have to backport all changes. 😰

s <- c("2", "11", "00", "10", "12", "011", "020", "021", "012", "022", 
"0100", "0102", "0101") 
init_g <- igraph::make_empty_graph(n=1)
igraph::V(init_g)$name <-""
g <- init_g
for (word in c(s)) {
   print(word)
    # turns "10100" into c("1","10","101","1010", 10100")
    subwords <- stringr::str_sub(word, 1, 1:nchar(word))
    # make a graph long enough to hold all those sub-words + start node
    subg <- igraph::graph.lattice(length(subwords)+1,directed=TRUE)
    # set vertex nodes to start node plus sub-words
    igraph::V(subg)$name <- c("",subwords)
    # merge *by name* into the existing graph
    g <- igraph::union(g, subg)
 }
#> [1] "2"
#> Warning: `graph.lattice()` was deprecated in igraph 2.0.4.
#> ℹ Please use `make_lattice()` instead.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.
#> [1] "11"
#> [1] "00"
#> [1] "10"
#> [1] "12"
#> [1] "011"
#> [1] "020"
#> [1] "021"
#> [1] "012"
#> [1] "022"
#> [1] "0100"
#> [1] "0102"
#> [1] "0101"

Created on 2024-07-19 with reprex v2.1.0

@maelle maelle added this to the 2.0.4 milestone Jul 19, 2024
@maelle maelle requested a review from krlmlr July 19, 2024 14:49
Copy link
Contributor

aviator-app bot commented Jul 19, 2024

Current Aviator status

Aviator will automatically update this comment as the status of the PR changes.
Comment /aviator refresh to force Aviator to re-examine your PR (or learn about other /aviator commands).

This PR was merged using Aviator.


See the real-time status of this PR on the Aviator webapp.
Use the Aviator Chrome Extension to see the status of your PR within GitHub.

@krlmlr krlmlr changed the title fix: align graph.lattice()'s body with its replacement make_lattice() fix: Align the body of graph.lattice() body with its replacement make_lattice() Jul 19, 2024
@krlmlr krlmlr changed the title fix: Align the body of graph.lattice() body with its replacement make_lattice() fix: Align the body of graph.lattice() with its replacement make_lattice() Jul 19, 2024
Copy link
Contributor

@krlmlr krlmlr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks!

on.exit(.Call(R_igraph_finalizer))
res <- square_lattice_impl(dimvector, nei, directed, mutual, periodic)
if (igraph_opt("add.params")) {
res$name <- "Lattice graph"
res$dimvector <- dimvector
res$nei <- nei
res$mutual <- mutual
res$circular <- circular
res$circular <- periodic
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps:

Suggested change
res$circular <- periodic
res$periodic <- periodic
res$circular <- periodic

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't have this in the original body copied here.

@aviator-app aviator-app bot merged commit 7fcc533 into main Aug 13, 2024
11 checks passed
@aviator-app aviator-app bot deleted the lattice branch August 13, 2024 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants