igraph
make_ring
: IGRAPH U--- 10 10 -- Ring graph
+ attr: name (g/c), mutual (g/x), circular (g/x)
IGRAPH
U
D
N
name
W
weight
B
type
Then come two numbers, the number of vertices and the number of edges
in the graph, and after a double dash, the name of the graph (the
name
name
mutual
circular
print.igraph
for
details.
If you want to see the edges of the graph as well, then use the
str.igraph
function, it is of course enough to type
str
instead of str.igraph
: > str(g)
IGRAPH U--- 10 10 -- Ring graph
+ attr: name (g/c), mutual (g/x), circular (g/x)
+ edges:
[1] 1-- 2 2-- 3 3-- 4 4-- 5 5-- 6 6-- 7 7-- 8 8-- 9 9--10 1--10
To create small graphs with a given structure probably the
graph_from_literal
function is easiest. It uses R's formula
interface, its manual page contains many examples. Another option is
graph
, which takes numeric vertex ids directly.
graph.atlas
creates graph from the Graph Atlas,
make_graph
can create some special graphs.
To create graphs from field data, graph_from_edgelist
,
graph_from_data_frame
and graph_from_adjacency_matrix
are
probably the best choices.
The igraph package includes some classic random graphs like the
Erdos-Renyi GNP and GNM graphs (sample_gnp
, sample_gnm
) and
some recent popular models, like preferential attachment
(sample_pa
) and the small-world model
(sample_smallworld
).
induced_subgraph
, then
the vertices are renumbered to satisfty this criteria.The same is true for the edges as well, edge ids are always between one and $m$, the total number of edges in the graph.
It is often desirable to follow vertices along a number of graph operations, and vertex ids don't allow this because of the renumbering. The solution is to assign attributes to the vertices. These are kept by all operations, if possible. See more about attributes in the next section.
vertex_attr
,
V
and E
for details. Some vertex/edge/graph attributes are treated specially. One of them
is the degree
has a v
argument
that gives the vertices for which the degree is calculated. This
argument can be given as a character vector of vertex names.
Edges can also have a delete_edges
and
other functions.
We note here, that vertex names can also be used to select edges.
The form from|to
from
to
from
to
Other attributes define visualization parameters, see
igraph.plotting
for details.
Attribute values can be set to any R object, but note that storing the
graph in some file formats might result the loss of complex attribute
values. All attribute values are preserved if you use
save
and load
to store/retrieve your
graphs.
plot.igraph
function. (Actually you don't need to
write plot.igraph
, plot
is enough. This function uses
regular R graphics and can be used with any R device. The second function is tkplot
, which uses a Tk GUI for
basic interactive graph manipulation. (Tk is quite resource hungry, so
don't try this for very large graphs.)
The third way requires the rgl
package and uses OpenGL. See the
rglplot
function for the details.
Make sure you read igraph.plotting
before you start
plotting your graphs.
read_graph
and
write_graph
for details.