Skip to content

Replace igraph calls with our own R code, get rid of igraph #152

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

Merged
merged 1 commit into from
May 18, 2016
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
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Imports:
stringdist,
testthat,
digest,
igraph,
rstudioapi (>= 0.2),
httr,
jsonlite,
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# lintr 1.0.0.9000 #
* lintr does not need the igraph package any more (#152, @gaborcsardi)

* trailing_semicolon_linter (#147, @gaborcsardi)

* Commas linter handles missing arguments calls properly (#145)
Expand Down
2 changes: 1 addition & 1 deletion R/get_source_expressions.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ get_source_expressions <- function(filename) {
content <- get_content(expr_lines, parsed_content[loc, ])

id <- as.character(parsed_content$id[loc])
edges <- igraph::E(tree)[from(igraph::subcomponent(tree, id, mode = "out"))]
edges <- component_edges(tree, id)
pc <- parsed_content[c(loc, edges), ]
list(
filename = filename,
Expand Down
26 changes: 25 additions & 1 deletion R/tree-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,32 @@ generate_tree <- function(pc) {
return(NULL)
}
edges <- matrix(as.character(c(pc$parent, pc$id)), ncol = 2)
igraph::graph.edgelist(edges, directed = TRUE)
list(edges = edges, adjlist = adjlist_from_edgelist(edges))
}

## Create an adjacency list from an edge list

adjlist_from_edgelist <- function(edges) {
tapply(edges[, 2], edges[, 1], c, simplify = FALSE)
}

## Take the subcomponent of id (mode out), and then all edges
## that start at these vertices

component_edges <- function(graph, id) {
sc <- newv <- unique(id)
size <- length(sc)
repeat {
neis <- unlist(graph$adjlist[newv])
newv <- setdiff(neis, sc)
sc <- c(sc, newv)
if (length(sc) == size) break;
size <- length(sc)
}

which(graph$edges[, 1] %in% sc)
}

children <- function(data, id, levels = Inf, simplify = TRUE) {

child_ids <- function(ids) {
Expand Down