Skip to content

Commit

Permalink
more linting
Browse files Browse the repository at this point in the history
  • Loading branch information
benyamindsmith committed May 30, 2024
1 parent eaa6ae9 commit 35b28c6
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 10 deletions.
6 changes: 3 additions & 3 deletions R/cluster_node_closeness.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ cluster_node_closeness <- function(
For the novel algorithm, please see cluster_degree_betweenness()")
graph_ <- graph
communities <- list()
community_list <- list()
community_list <- append(communities, clusters(graph_)$membership)
#community_list <- list()
#community_list <- append(communities, clusters(graph_)$membership)
closeness_nodes <- names(sort(closeness(graph_),decreasing = TRUE))
communities_list <- list()
subgraphs <- list()
Expand Down Expand Up @@ -83,7 +83,7 @@ cluster_node_closeness <- function(

graph_ <- graph

for(i in 1:length(communities)){
for(i in seq_along(1:length(communities))){
graph_names<- names(V(graph_))
cumulative_communities <- unlist(communities[1:i])
cumulative_communities_deduplicated <- cumulative_communities |>
Expand Down
9 changes: 5 additions & 4 deletions R/cluster_node_degree.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ cluster_node_degree <- function(
For the novel algorithm, please see cluster_degree_betweenness()")
graph_ <- graph
communities <- list()
community_list <- list()
community_list <- append(communities, clusters(graph_)$membership)
# Removing this line to satisfy the lintr
#community_list <- list()
#community_list <- append(communities, clusters(graph_)$membership)
degree_nodes <- names(sort(degree(graph_),decreasing = TRUE))
communities_list <- list()
subgraphs <- list()
Expand Down Expand Up @@ -76,8 +77,8 @@ cluster_node_degree <- function(
}

graph_ <- graph

for(i in 1:length(communities)){
# Adding seq_along to satisfy lintr.
for(i in seq_along(1:length(communities))){
graph_names<- names(V(graph_))
cumulative_communities <- unlist(communities[1:i])
cumulative_communities_deduplicated <- cumulative_communities |>
Expand Down
2 changes: 1 addition & 1 deletion R/prep_unlabeled_graph.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ prep_unlabeled_graph <- function(graph) {
prepared_graph <-
igraph::set_vertex_attr(graph, "name", value = 1:vcount(graph))

} else{
} else {
prepared_graph <- graph
}
return(prepared_graph)
Expand Down
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,24 @@ main= "Smith-Pittman Clustering"

# Limitations

The present limitations of using this algorithm is that graphs are required to be labeled for the operations to work. For unlabled graphs, graphs can be prepared with the `prep_unlabled_graph()` function.
The present limitations of using this algorithm is that graphs are required to be labeled for the operations to work. For unlabeled graphs, graphs can be prepared with the `prep_unlabled_graph()` function.

Example:

```r
library(igraph)
library(igraphdata)
library(ig.degree.betweenness)
data("UKfaculty")
# Making graph undirected so it looks nicer when its plotted
uk_faculty <- prep_unlabeled_graph(UKfaculty) |>
as.undirected()

ndb <- cluster_degree_betweenness(uk_faculty)

plot(
ndb,
uk_faculty,
main= "Smith-Pittman Clustering"
)
```
2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ pandoc: 3.1.1
pkgdown: 2.0.7
pkgdown_sha: ~
articles: {}
last_built: 2024-05-15T04:05Z
last_built: 2024-05-30T16:32Z

Binary file modified docs/reference/Rplot001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/reference/cluster_degree_betweenness-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/reference/prep_unlabeled_graph-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 35b28c6

Please sign in to comment.