Graphics Reference
In-Depth Information
Figure 13-7. Left: a directed graph; right: an undirected graph, with no vertex labels
This is the structure of each of the graph objects:
str(gd)
IGRAPH D
---
6 6
--
+
edges:
[
1
]
1
->
2 2
->
3 2
->
4 1
->
4 5
->
5 3
->
6
str(gu)
IGRAPH U
---
6 6
--
+
edges:
[
1
]
1
-
-2 2
-
-3 2
-
-4 1
-
-4 5
-
-5 3
-
-6
Discussion
In a network graph, the position of the nodes is unspecified by the data, and they're placed ran-
domly. To make the output repeatable, you can set the random seed before making the plot. You
can try different random numbers until you get a result that you like:
set.seed(
229
)
plot(gu)
It's also possible to create a graph from a data frame. The first two rows of the data frame are
used, and each row specifies a connection between two nodes. In the next example (
Figure 13-8
)
,