Skip to content
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
2 changes: 1 addition & 1 deletion R/adjacency.R
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ graph.adjacency.sparse <- function(adjmatrix, mode = c(
res <- add_edges(res, edges = t(as.matrix(el[, 1:2])), attr = weight)
} else {
edges <- unlist(apply(el, 1, function(x) rep(unname(x[1:2]), x[3])))
res <- graph(n = vc, edges, directed = (mode == "directed"))
res <- make_graph(n = vc, edges, directed = (mode == "directed"))
}
res
}
Expand Down
2 changes: 1 addition & 1 deletion R/attributes.R
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ igraph.i.attribute.combination <- function(comb) {
#' @keywords graphs
#' @examples
#'
#' g <- graph(c(1, 2, 1, 2, 1, 2, 2, 3, 3, 4))
#' g <- make_graph(c(1, 2, 1, 2, 1, 2, 2, 3, 3, 4))
#' E(g)$weight <- 1:5
#'
#' ## print attribute values with the graph
Expand Down
14 changes: 7 additions & 7 deletions R/centrality.R
Original file line number Diff line number Diff line change
Expand Up @@ -1194,10 +1194,10 @@ bonpow.sparse <- function(graph, nodes = V(graph), loops = FALSE,
#' @examples
#'
#' # Generate some test data from Bonacich, 1987:
#' g.c <- graph(c(1, 2, 1, 3, 2, 4, 3, 5), dir = FALSE)
#' g.d <- graph(c(1, 2, 1, 3, 1, 4, 2, 5, 3, 6, 4, 7), dir = FALSE)
#' g.e <- graph(c(1, 2, 1, 3, 1, 4, 2, 5, 2, 6, 3, 7, 3, 8, 4, 9, 4, 10), dir = FALSE)
#' g.f <- graph(
#' g.c <- make_graph(c(1, 2, 1, 3, 2, 4, 3, 5), dir = FALSE)
#' g.d <- make_graph(c(1, 2, 1, 3, 1, 4, 2, 5, 3, 6, 4, 7), dir = FALSE)
#' g.e <- make_graph(c(1, 2, 1, 3, 1, 4, 2, 5, 2, 6, 3, 7, 3, 8, 4, 9, 4, 10), dir = FALSE)
#' g.f <- make_graph(
#' c(1, 2, 1, 3, 1, 4, 2, 5, 2, 6, 2, 7, 3, 8, 3, 9, 3, 10, 4, 11, 4, 12, 4, 13),
#' dir = FALSE
#' )
Expand Down Expand Up @@ -1379,9 +1379,9 @@ alpha.centrality.sparse <- function(graph, nodes = V(graph), alpha = 1,
#' @examples
#'
#' # The examples from Bonacich's paper
#' g.1 <- graph(c(1, 3, 2, 3, 3, 4, 4, 5))
#' g.2 <- graph(c(2, 1, 3, 1, 4, 1, 5, 1))
#' g.3 <- graph(c(1, 2, 2, 3, 3, 4, 4, 1, 5, 1))
#' g.1 <- make_graph(c(1, 3, 2, 3, 3, 4, 4, 5))
#' g.2 <- make_graph(c(2, 1, 3, 1, 4, 1, 5, 1))
#' g.3 <- make_graph(c(1, 2, 2, 3, 3, 4, 4, 1, 5, 1))
#' alpha_centrality(g.1)
#' alpha_centrality(g.2)
#' alpha_centrality(g.3, alpha = 0.5)
Expand Down
2 changes: 1 addition & 1 deletion R/centralization.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ NULL
#' centralize(deg, tmax)
#'
#' # The most centralized graph according to eigenvector centrality
#' g0 <- graph(c(2, 1), n = 10, dir = FALSE)
#' g0 <- make_graph(c(2, 1), n = 10, dir = FALSE)
#' g1 <- make_star(10, mode = "undirected")
#' centr_eigen(g0)$centralization
#' centr_eigen(g1)$centralization
Expand Down
2 changes: 1 addition & 1 deletion R/conversion.R
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ as_edgelist <- function(graph, names = TRUE) {
#' plot(ug3, layout = layout_in_circle, edge.label = E(ug3)$weight)
#' }
#'
#' g4 <- graph(c(
#' g4 <- make_graph(c(
#' 1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 4,
#' 6, 7, 7, 6, 7, 8, 7, 8, 8, 7, 8, 9, 8, 9,
#' 9, 8, 9, 8, 9, 9, 10, 10, 10, 10
Expand Down
4 changes: 2 additions & 2 deletions R/data_frame.R
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,12 @@ graph_from_edgelist <- function(el, directed = TRUE) {
names <- unique(as.character(t(el)))
ids <- seq(names)
names(ids) <- names
res <- graph(unname(ids[t(el)]), directed = directed)
res <- make_graph(unname(ids[t(el)]), directed = directed)
rm(ids)
V(res)$name <- names
} else {
## normal edge list
res <- graph(t(el), directed = directed)
res <- make_graph(t(el), directed = directed)
}
}

Expand Down
2 changes: 1 addition & 1 deletion R/flow.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
#' min_cut(g, capacity = rep(1, vcount(g)))
#' min_cut(g, value.only = FALSE, capacity = rep(1, vcount(g)))
#'
#' g2 <- graph(c(1, 2, 2, 3, 3, 4, 1, 6, 6, 5, 5, 4, 4, 1))
#' g2 <- make_graph(c(1, 2, 2, 3, 3, 4, 1, 6, 6, 5, 5, 4, 4, 1))
#' E(g2)$capacity <- c(3, 1, 2, 10, 1, 3, 2)
#' min_cut(g2, value.only = FALSE)
#' @family flow
Expand Down
2 changes: 1 addition & 1 deletion R/hrg.R
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ as.igraph.igraphHRG <- function(x, ...) {
ll <- ifelse(x$left < 0, -x$left + ovc, x$left + 1)
rr <- ifelse(x$right < 0, -x$right + ovc, x$right + 1)
edges <- c(rbind(seq_len(ivc) + ovc, ll), rbind(seq_len(ivc) + ovc, rr))
res <- graph(edges)
res <- make_graph(edges)

V(res)$name <- c(
if (!is.null(x$names)) x$names else as.character(1:ovc),
Expand Down
2 changes: 1 addition & 1 deletion R/incidence.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ graph.incidence.sparse <- function(incidence, directed, mode, multiple,
}

edges <- unlist(apply(el, 1, function(x) rep(unname(x[1:2]), x[3])))
res <- graph(n = n1 + n2, edges, directed = directed)
res <- make_graph(n = n1 + n2, edges, directed = directed)
}

set_vertex_attr(res, "type", value = c(rep(FALSE, n1), rep(TRUE, n2)))
Expand Down
6 changes: 3 additions & 3 deletions R/iterators.R
Original file line number Diff line number Diff line change
Expand Up @@ -458,21 +458,21 @@ simple_vs_index <- function(x, i, na_ok = FALSE) {
#'
#' # -----------------------------------------------------------------
#' # nei() special function
#' g <- graph(c(1, 2, 2, 3, 2, 4, 4, 2))
#' g <- make_graph(c(1, 2, 2, 3, 2, 4, 4, 2))
#' V(g)[.nei(c(2, 4))]
#' V(g)[.nei(c(2, 4), "in")]
#' V(g)[.nei(c(2, 4), "out")]
#'
#' # -----------------------------------------------------------------
#' # The same with vertex names
#' g <- graph(~ A -+ B, B -+ C:D, D -+ B)
#' g <- make_graph(~ A -+ B, B -+ C:D, D -+ B)
#' V(g)[.nei(c("B", "D"))]
#' V(g)[.nei(c("B", "D"), "in")]
#' V(g)[.nei(c("B", "D"), "out")]
#'
#' # -----------------------------------------------------------------
#' # Resolving attributes
#' g <- graph(~ A -+ B, B -+ C:D, D -+ B)
#' g <- make_graph(~ A -+ B, B -+ C:D, D -+ B)
#' V(g)$color <- c("red", "red", "green", "green")
#' V(g)[color == "red"]
#'
Expand Down
2 changes: 1 addition & 1 deletion R/make.R
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ graph_from_literal_i <- function(mf) {

ids <- seq(along.with = v)
names(ids) <- v
res <- graph(unname(ids[edges]), n = length(v), directed = directed)
res <- make_graph(unname(ids[edges]), n = length(v), directed = directed)
if (simplify) res <- simplify(res)
res <- set_vertex_attr(res, "name", value = v)
res
Expand Down
2 changes: 1 addition & 1 deletion R/plot.common.R
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ i.postprocess.layout <- function(maybe_layout) {
#' @keywords graphs
#' @examples
#'
#' g <- graph(c(
#' g <- make_graph(c(
#' 0, 1, 1, 0, 1, 2, 1, 3, 1, 3, 1, 3,
#' 2, 3, 2, 3, 2, 3, 2, 3, 0, 1
#' ) + 1)
Expand Down
2 changes: 1 addition & 1 deletion R/simple.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
#' @keywords graphs
#' @examples
#'
#' g <- graph(c(1, 2, 1, 2, 3, 3))
#' g <- make_graph(c(1, 2, 1, 2, 3, 3))
#' is_simple(g)
#' is_simple(simplify(g, remove.loops = FALSE))
#' is_simple(simplify(g, remove.multiple = FALSE))
Expand Down
4 changes: 2 additions & 2 deletions R/structural.properties.R
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,7 @@ reciprocity <- function(graph, ignore.loops = TRUE,
#' g3 <- sample_gnp(n = 10, 0.4)
#'
#' # loop edges
#' g <- graph(c(1, 2, 2, 2, 2, 3)) # graph with a self-loop
#' g <- make_graph(c(1, 2, 2, 2, 2, 3)) # graph with a self-loop
#' edge_density(g, loops = FALSE) # this is wrong!!!
#' edge_density(g, loops = TRUE) # this is right!!!
#' edge_density(simplify(g), loops = FALSE) # this is also right, but different
Expand Down Expand Up @@ -1522,7 +1522,7 @@ girth <- function(graph, circle = TRUE) {
#' @examples
#'
#' # Loops
#' g <- graph(c(1, 1, 2, 2, 3, 3, 4, 5))
#' g <- make_graph(c(1, 1, 2, 2, 3, 3, 4, 5))
#' any_loop(g)
#' which_loop(g)
#'
Expand Down
8 changes: 4 additions & 4 deletions demo/crashR.R
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ pause()
### Graphs
## Create a small graph, A->B, A->C, B->C, C->E, D
## A=1, B=2, C=3, D=4, E=5
g <- graph(c(1, 2, 1, 3, 2, 3, 3, 5), n = 5)
g <- make_graph(c(1, 2, 1, 3, 2, 3, 3, 5), n = 5)

pause()

Expand All @@ -180,7 +180,7 @@ pause()

### Create an undirected graph as well
## A--B, A--C, B--C, C--E, D
g2 <- graph(c(1, 2, 1, 3, 2, 3, 3, 5), n = 5, dir = FALSE)
g2 <- make_graph(c(1, 2, 1, 3, 2, 3, 3, 5), n = 5, dir = FALSE)
g2

pause()
Expand Down Expand Up @@ -215,7 +215,7 @@ as.directed(as.undirected(g))
pause()

### Multiple edges
g <- graph(c(1, 2, 1, 2, 1, 3, 2, 3, 4, 5), n = 5)
g <- make_graph(c(1, 2, 1, 2, 1, 3, 2, 3, 4, 5), n = 5)
g

is_simple(g)
Expand All @@ -230,7 +230,7 @@ is_simple(g)
pause()

### Loop edges
g <- graph(c(1, 1, 1, 2, 1, 3, 2, 3, 4, 5), n = 5)
g <- make_graph(c(1, 1, 1, 2, 1, 3, 2, 3, 4, 5), n = 5)
g

is_simple(g)
Expand Down
6 changes: 3 additions & 3 deletions man/alpha_centrality.Rd

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

2 changes: 1 addition & 1 deletion man/as.directed.Rd

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

2 changes: 1 addition & 1 deletion man/centralize.Rd

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

2 changes: 1 addition & 1 deletion man/curve_multiple.Rd

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

2 changes: 1 addition & 1 deletion man/edge_density.Rd

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

2 changes: 1 addition & 1 deletion man/igraph-attribute-combination.Rd

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

6 changes: 3 additions & 3 deletions man/igraph-vs-indexing.Rd

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

2 changes: 1 addition & 1 deletion man/min_cut.Rd

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

8 changes: 4 additions & 4 deletions man/power_centrality.Rd

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

2 changes: 1 addition & 1 deletion man/simplify.Rd

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

2 changes: 1 addition & 1 deletion man/which_multiple.Rd

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

12 changes: 6 additions & 6 deletions tests/testthat/test-alpha.centrality.R
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
test_that("dense alpha_centrality works", {
g.1 <- graph(c(1, 3, 2, 3, 3, 4, 4, 5))
g.1 <- make_graph(c(1, 3, 2, 3, 3, 4, 4, 5))
ac1 <- alpha_centrality(g.1, sparse = FALSE)
expect_that(ac1, equals(c(1, 1, 3, 4, 5)))

g.2 <- graph(c(2, 1, 3, 1, 4, 1, 5, 1))
g.2 <- make_graph(c(2, 1, 3, 1, 4, 1, 5, 1))
ac2 <- alpha_centrality(g.2, sparse = FALSE)
expect_that(ac2, equals(c(5, 1, 1, 1, 1)))

g.3 <- graph(c(1, 2, 2, 3, 3, 4, 4, 1, 5, 1))
g.3 <- make_graph(c(1, 2, 2, 3, 3, 4, 4, 1, 5, 1))
ac3 <- alpha_centrality(g.3, alpha = 0.5, sparse = FALSE)
expect_that(ac3, equals(c(76, 68, 64, 62, 30) / 30))
})

test_that("sparse alpha_centrality works", {
g.1 <- graph(c(1, 3, 2, 3, 3, 4, 4, 5))
g.1 <- make_graph(c(1, 3, 2, 3, 3, 4, 4, 5))
ac1 <- alpha_centrality(g.1, sparse = TRUE)
expect_that(ac1, equals(c(1, 1, 3, 4, 5)))

g.2 <- graph(c(2, 1, 3, 1, 4, 1, 5, 1))
g.2 <- make_graph(c(2, 1, 3, 1, 4, 1, 5, 1))
ac2 <- alpha_centrality(g.2, sparse = TRUE)
expect_that(ac2, equals(c(5, 1, 1, 1, 1)))

g.3 <- graph(c(1, 2, 2, 3, 3, 4, 4, 1, 5, 1))
g.3 <- make_graph(c(1, 2, 2, 3, 3, 4, 4, 1, 5, 1))
ac3 <- alpha_centrality(g.3, alpha = 0.5, sparse = TRUE)
expect_that(ac3, equals(c(76, 68, 64, 62, 30) / 30))
})
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-are.connected.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ test_that("are_adjacent works", {
expect_true(are_adjacent(g, "B", "A"))
expect_false(are_adjacent(g, "A", "D"))

g2 <- graph(c(1, 2, 2, 3, 3, 4), dir = FALSE)
g2 <- make_graph(c(1, 2, 2, 3, 3, 4), dir = FALSE)
expect_true(are_adjacent(g2, 1, 2))
expect_true(are_adjacent(g2, 3, 2))
expect_false(are_adjacent(g2, 4, 1))
Expand Down
Loading