igraph (version 1.0.0)

make_graph: Create an igraph graph from a list of edges, or a notable graph

Description

Create an igraph graph from a list of edges, or a notable graph

Usage

make_graph(edges, ..., n = max(edges), isolates = NULL, directed = TRUE,
  dir = directed, simplify = TRUE)

make_directed_graph(edges, n = max(edges))

make_undirected_graph(edges, n = max(edges))

directed_graph(...)

undirected_graph(...)

Arguments

edges
A vector defining the edges, the first edge points from the first element to the second, the second edge from the third to the fourth, etc. For a numeric vector, these are interpreted as internal vertex ids. For character vectors, they are interpret
...
For make_graph: extra arguments for the case when the graph is given via a literal, see graph_from_literal. For directed_graph and undirected_graph: Passed
n
The number of vertices in the graph. This argument is ignored (with a warning) if edges are symbolic vertex names. It is also ignored if there is a bigger vertex id in edges. This means that for this function it is safe to supply
isolates
Character vector, names of isolate vertices, for symbolic edge lists. It is ignored for numeric edge lists.
directed
Whether to create a directed graph.
dir
It is the same as directed, for compatibility. Do not give both of them.
simplify
For graph literals, whether to simplify the graph.

Value

  • An igraph graph.

encoding

UTF-8

See Also

Other determimistic constructors: atlas, graph.atlas, graph_from_atlas; chordal_ring, graph.extended.chordal.ring, make_chordal_ring; empty_graph, graph.empty, make_empty_graph; from_edgelist, graph.edgelist, graph_from_edgelist; from_literal, graph.formula, graph_from_literal; full_citation_graph, graph.full.citation, make_full_citation_graph; full_graph, graph.full, make_full_graph; graph.lattice, lattice, make_lattice; graph.ring, make_ring, ring; graph.star, make_star, star; graph.tree, make_tree, tree

Examples

Run this code
make_graph(c(1, 2, 2, 3, 3, 4, 5, 6), directed = FALSE)
make_graph(c("A", "B", "B", "C", "C", "D"), directed = FALSE)

solids <- list(make_graph("Tetrahedron"),
               make_graph("Cubical"),
               make_graph("Octahedron"),
               make_graph("Dodecahedron"),
               make_graph("Icosahedron"))

graph <- make_graph( ~ A-B-C-D-A, E-A:B:C:D,
                      F-G-H-I-F, J-F:G:H:I,
                      K-L-M-N-K, O-K:L:M:N,
                      P-Q-R-S-P, T-P:Q:R:S,
                      B-F, E-J, C-I, L-T, O-T, M-S,
                      C-P, C-L, I-L, I-P)

Run the code above in your browser using DataCamp Workspace