Skip to content

Commit

Permalink
good example
Browse files Browse the repository at this point in the history
  • Loading branch information
benyamindsmith committed Nov 1, 2024
1 parent 6eac26f commit 3049d4b
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 8 deletions.
37 changes: 33 additions & 4 deletions R/plot_simplified_edgeplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,40 @@
#' @param communities optional; A communities object
#' @param ... other arguments to be passed to the `plot()` function
#' @examples
#' # Create an igraph object
#' my_graph <- igraph::make_ring(10)
#' # Plot the simplified edge plot
#' plot_simplified_edgeplot(my_graph)
#'# Load the igraph package
#' library(igraph)
#' library(ig.degree.betweenness)
#' # Set parameters
#' num_nodes <- 17 # Number of nodes (adjust as needed)
#' initial_edges <- 1 # Starting edges for preferential attachment
#'
#' # Create a directed, scale-free network using the Barabási-Albert model
#' g <- sample_pa(n = num_nodes, m = initial_edges, directed = TRUE)
#'
#' # Introduce additional edges to high-degree nodes to accentuate popularity differences
#' num_extra_edges <- 350 # Additional edges to create more popular nodes
#' set.seed(123) # For reproducibility
#'
#' for (i in 1:num_extra_edges) {
#' # Sample nodes with probability proportional to their degree (to reinforce popularity)
#' from <- sample(V(g), 1, prob = degree(g, mode = "in") + 1) # +1 to avoid zero probabilities
#' to <- sample(V(g), 1)
#'
#' # Ensure we don't add the same edge repeatedly unless intended, allowing self-loops
#' g <- add_edges(g, c(from, to))
#' }
#'
#' # Add self-loops to a subset of nodes
#' num_self_loops <- 5
#' for (i in 1:num_self_loops) {
#' node <- sample(V(g), 1)
#' g <- add_edges(g, c(node, node))
#' }
#'
#'
#' g_ <- ig.degree.betweenness::prep_unlabeled_graph(g)
#'
#' ig.degree.betweenness::plot_simplified_edgeplot(g_,main="Simulated Data")
#' @export

plot_simplified_edgeplot <- function(graph,
Expand Down
37 changes: 33 additions & 4 deletions man/plot_simplified_edgeplot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3049d4b

Please sign in to comment.