11---
2+ engine : knitr
23format :
34 html :
45 embed-resources : true
@@ -83,7 +84,7 @@ This object is essentially a data frame that contains the x–y coordinates of e
8384
8485With R installed:
8586
86- ``` r
87+ ``` {r}
8788install.packages("graphlayouts")
8889```
8990
@@ -98,7 +99,7 @@ After installing the package and its dependencies you can start visualizing netw
9899### Create or load a graph
99100Graphs can be created manually or loaded from existing datasets. For example:
100101
101- ``` r
102+ ``` {r}
102103library(igraph)
103104g <- make_ring(10) # simple ring graph with 10 nodes
104105```
@@ -112,7 +113,7 @@ Use `create_layout()` from `ggraph` with one of the following layout options pro
112113- ` "backbone" ` – highlights the backbone structure of a network while de-emphasizing weaker connections.
113114- ` "centrality" ` – arranges nodes according to a chosen centrality measure (e.g., degree or betweenness).
114115
115- ``` r
116+ ``` {r}
116117library(graphlayouts)
117118library(ggraph)
118119
@@ -125,7 +126,7 @@ With a layout prepared, you can visualize the graph using `ggraph` layers.
125126- ** Nodes** : use ` geom_node_point() ` for basic dots, ` geom_node_text() ` for labels, or scale aesthetics (size, color, fill) by node attributes.
126127- ** Edges** : use ` geom_edge_link() ` for straight lines, ` geom_edge_arc() ` for curved arcs, or directional edges with arrows.
127128
128- ``` r
129+ ``` {r}
129130ggraph(lay) +
130131 geom_edge_link(alpha = 0.5) +
131132 geom_node_point(size = 5, color = "steelblue") +
@@ -136,7 +137,7 @@ ggraph(lay) +
136137You can customize almost every aspect of the plot:
137138- ** Node size or color** can map to graph metrics:
138139
139- ``` r
140+ ``` {r}
140141V(g)$deg <- degree(g)
141142ggraph(lay) +
142143 geom_edge_link(alpha = 0.3) +
0 commit comments