Skip to content

Commit 5e13858

Browse files
committed
Merge branch 'main' of github.com:schochastics/graphlayouts
2 parents 7c3d751 + ec7b2b7 commit 5e13858

1 file changed

Lines changed: 148 additions & 27 deletions

File tree

methodshub.qmd

Lines changed: 148 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,44 @@
11
---
2-
title: graphlayouts - Additional Layout Algorithms for Network Visualizations
32
format:
43
html:
54
embed-resources: true
65
gfm: default
76
---
87

9-
## Description
8+
# graphlayouts - Additional Layout Algorithms for Network Visualizations
9+
<!--
10+
General specifications:
11+
- This specification of the Methods Hub friendly README often uses the word 'should' to indicate the usual case. If you feel you need to do it differently, add a comment to argue for your case when you submit your method.
12+
- A Methods Hub friendly README should contain all sections below that are not marked as optional, and can contain more sections.
13+
- A Methods Hub friendly README should contain as few technical terms as possible and explain (or link to an explanation of) all used technical terms.
14+
- A Methods Hub friendly README should link to all code files that it mentions using the [text](URL relative to this file) format. The relative URL (i.e., no "https://github.com") is neccessary for proper versioning in Methods Hub.
15+
- A Methods Hub friendly README should contain an explanation (in the text) and an alternative for each image it contains (e.g., data models, pipeline, schema structure). Format: ![alternative text that describes what is visible in the image](URL relative to this file).
16+
- A Methods Hub friendly README should link to authoritative sources rather than containing a copy of the information (e.g., documentation).
17+
- A Methods Hub friendly README should use a uniform citation style for all references, for example APA7 https://apastyle.apa.org/style-grammar-guidelines/references/examples
18+
19+
Title:
20+
1. The title must be the README's only first-level heading (line starting with a single '#').
21+
2. The title should make the method's purpose clear.
22+
3. The title (line 1 of this file) must be changed by you, but all other headings should be kept as they are.
23+
4. The title must be appropriate (not harmful, derogatory, etc.).
24+
25+
Section templates:
26+
The README template comes with text templates for each section (after each comment) that can be used, customized or removed as desired.
27+
-->
1028

11-
<!-- - Provide a brief and clear description of the method, its purpose, and what it aims to achieve. Add a link to a related paper from social science domain and show how your method can be applied to solve that research question. -->
29+
## Description
30+
<!--
31+
1. Provide a brief and exact description of the method clearly mentioning its purpose i.e., what the method does or aims to achieve in abstract terms (avoiding technical details).
32+
2. The focus should be on explaining the method in a way that helps users with different levels of expertise understand what it does, without going into technical details. It should clearly describe what inputs are needed and what outputs can be expected.
33+
3. Briefly explain the input and output of the method and its note worthy features.
34+
4. Provide link(s) to related papers from the social science domain using the method or similar methods for solving social science research questions.
35+
5. In a separate paragraph, highlight the reproducibility aspect of the method providing details or references to the resources used by the method, the data used in building the pre-trained modules etc.
36+
6. It should also discuss the decisions and parameters controlling the behavior of the method.
37+
-->
1238

1339
The package implements several new layout algorithms to visualize networks are provided which are not part of 'igraph'.
1440
Most are based on the concept of stress majorization by Gansner et al. (2004) <doi:10.1007/978-3-540-31843-9_25>.
15-
Some more specific algorithms allow the user to emphasize hidden group structures in networks or focus on specific nodes.
41+
Some more specific algorithms allow the user to emphasize hidden group structures in networks or focus on specific nodes..
1642

1743
## Keywords
1844

@@ -22,55 +48,150 @@ Some more specific algorithms allow the user to emphasize hidden group structure
2248
* Network Visualization
2349
* Network layouts
2450

25-
## Science Usecase(s)
51+
## Use Cases
52+
<!--
53+
1. The use cases section should contain a list of use cases relevant to the social sciences.
54+
2. Each use case should start with a description of a task and then detail how one can use the method to assist in the task.
55+
3. Each use case may list publications in which the use case occurs (e.g., in APA7 style, https://apastyle.apa.org/style-grammar-guidelines/references/examples).
56+
-->
2657

2758
Network visualization offers social scientists a powerful tool for analyzing relationships and interactions within digital traces. For instance, researchers studying online communities can use network visualization to map interactions on social media platforms, such as X or Reddit. By visualizing user interactions (like replies, mentions, or shared links), researchers can uncover patterns in information flow, identify influential users, and explore the formation of communities or echo chambers. Network visualization can reveal clusters of users who frequently engage with one another, suggesting tightly-knit subgroups with shared interests or beliefs. It also helps identify key influencers within these networks, who may play a critical role in spreading information or shaping public opinion. This analysis is particularly useful for understanding phenomena like misinformation spread, public discourse on sensitive topics, or the social dynamics of online activism, offering insights into how ideas and behaviors propagate through digital spaces.
2859

29-
## Repository structure
60+
## Input Data
61+
<!--
62+
1. The input data section should illustrate the input data format by showing a (possibly abbreviated) example item and explaining (or linking to an explanation of) the data fields.
63+
2. The input data section should specify which parts of the input data are optional and what effect it has to not provide these.
64+
3. The input data section should link to a small example input file in the same repository that can be used to test the method (this test should be described in the section "How to Use").
65+
-->
66+
67+
`graphlayouts` accepts `igraph` network objects as input and includes many datasets that can be used to test the layout algorithms.
68+
69+
## Output Data
70+
<!--
71+
1. The output data section should illustrate the output data format by showing a (possibly abbreviated) example item and explaining (or linking to an explanation of) the data fields.
72+
2. The output data section should link to a small example output file in the same repository that can be re-created (as far as the method is non-random) from the input data (as described in the section "How to Use").
73+
-->
3074

31-
This repository follows [the standard structure of an R package](https://cran.r-project.org/doc/FAQ/R-exts.html#Package-structure).
75+
The output of `graphlayouts` is a layout object created with `create_layout()` from `ggraph`.
76+
This object is essentially a data frame that contains the x–y coordinates of each node, along with any node attributes from the input graph. It can be directly passed into plotting functions in `ggraph`.
3277

3378
## Environment Setup
79+
<!--
80+
1. The environment setup section should list all requirements and provide all further steps to prepare an environment for running the method (installing requirements, downloading files, creating directoriees, etc.).
81+
2. The environment setup section should recommend to use a virtual environment or similar if the programming language supports one.
82+
-->
3483

3584
With R installed:
3685

3786
```r
3887
install.packages("graphlayouts")
3988
```
4089

41-
<!-- ## Hardware Requirements (Optional) -->
42-
<!-- - The hardware requirements may be needed in specific cases when a method is known to require more memory/compute power. -->
43-
<!-- - The method need to be executed on a specific architecture (GPUs, Hadoop cluster etc.) -->
90+
## How to Use
91+
<!--
92+
1. The how to use section should provide the list of steps that are necessary to produce the example output file (see section Output Data) after having set up the environment (see section Environment Setup).
93+
2. The how to use section should explain how to customize the steps to one's own needs, usually through configuration files or command line parameters, or refer to the appropriate open documentation.
94+
-->
4495

96+
After installing the package and its dependencies you can start visualizing networks with `graphlayouts` and the `ggraph` plotting framework.
4597

46-
## Input Data
98+
### Create or load a graph
99+
Graphs can be created manually or loaded from existing datasets. For example:
47100

48-
<!-- - The input data has to be a Digital Behavioral Data (DBD) Dataset -->
49-
<!-- - You can provide link to a public DBD dataset. GESIS DBD datasets (https://www.gesis.org/en/institute/digital-behavioral-data) -->
101+
```r
102+
library(igraph)
103+
g <- make_ring(10) # simple ring graph with 10 nodes
104+
```
50105

51-
<!-- This is an example -->
106+
### Choose a layout algorithm
107+
The core contribution of `graphlayouts` is a collection of layout algorithms not included in base `igraph`. Layouts are deterministic (they give the same result each time) and often based on *stress majorization*, which aims to preserve graph-theoretic distances in 2D space.
52108

53-
`graphlayouts` accepts `igraph` network objects as input.
109+
Use `create_layout()` from `ggraph` with one of the following layout options provided by `graphlayouts`:
110+
- `"stress"` – general-purpose layout that minimizes stress in node placement.
111+
- `"focus"` – emphasizes the position of one or more focal nodes.
112+
- `"backbone"` – highlights the backbone structure of a network while de-emphasizing weaker connections.
113+
- `"centrality"` – arranges nodes according to a chosen centrality measure (e.g., degree or betweenness).
54114

55-
## Sample Input and Output Data
115+
```r
116+
library(graphlayouts)
117+
library(ggraph)
56118

57-
The R package `networkdata` includes many datasets that can be used to test the layout algorithms.
119+
lay <- create_layout(g, layout = "stress")
120+
```
58121

59-
## How to Use
122+
### Draw the network with `ggraph`
123+
With a layout prepared, you can visualize the graph using `ggraph` layers.
60124

61-
You can find a tutorial [here](ADD METHODS LINK)
125+
- **Nodes**: use `geom_node_point()` for basic dots, `geom_node_text()` for labels, or scale aesthetics (size, color, fill) by node attributes.
126+
- **Edges**: use `geom_edge_link()` for straight lines, `geom_edge_arc()` for curved arcs, or directional edges with arrows.
62127

63-
## Contact Details
128+
```r
129+
ggraph(lay) +
130+
geom_edge_link(alpha = 0.5) +
131+
geom_node_point(size = 5, color = "steelblue") +
132+
theme_graph()
133+
```
64134

65-
Maintainer: David Schoch <[email protected]>
135+
### Customize appearance
136+
You can customize almost every aspect of the plot:
137+
- **Node size or color** can map to graph metrics:
66138

67-
Issue Tracker: [https://github.com/schochastics/graphlayouts/issues](https://github.com/schochastics/graphlayouts/issues)
139+
```r
140+
V(g)$deg <- degree(g)
141+
ggraph(lay) +
142+
geom_edge_link(alpha = 0.3) +
143+
geom_node_point(aes(size = deg), color = "tomato") +
144+
theme_graph()
145+
```
146+
147+
- **Edge thickness or color** can map to weights or categories.
148+
- **Labels** can be added with `geom_node_text()` or `geom_node_label()`.
149+
- **Themes and palettes**: use `theme_graph()` for a clean default or apply any ggplot2 scales (e.g., `scale_fill_viridis_c()`).
150+
151+
### Explore alternatives
152+
`graphlayouts` is particularly useful when different research questions call for different visual emphases:
153+
- Use `"focus"` layouts to visualize networks from the perspective of a key actor.
154+
- Use `"backbone"` layouts to highlight community structures.
155+
- Compare multiple layouts to see how structural features (clusters, bridges, hubs) appear under different perspectives.
156+
157+
158+
You can find a complete tutorial [here](https://methodshub.gesis.org/library/tutorials/network-visualizations-in-r/)
159+
160+
## Technical Details
161+
<!--
162+
1. The technical details section should proview a process overview, linking to key source code files at every step of the process.
163+
2. In case a publication provides the details mentioned below, the technical details section should link to this publication using a sentence like "See the [publication](url-of-publication-best-using-doi) for ...". In this case, the mentioned technical details can be omitted from the section.
164+
3. The technical details section should list all information needed to reproduce the method, including employed other methods and selected parameters.
165+
4. The input data section should link to external data it uses, preferably using a DOI to a dataset page or to API documentation.
166+
5. The technical details section should mention how other methods and their parameters were selected and which alternatives were tried.
167+
6. The technical details section should for employed machine learning models mention on what kind of data they were trained.
168+
-->
68169

69-
<!-- ## Publication -->
70-
<!-- - Include information on publications or articles related to the method, if applicable. -->
170+
See the official [CRAN page](https://doi.org/10.32614/CRAN.package.graphlayouts) for further information about technical details.
171+
172+
<!--## References -->
173+
<!--
174+
1. The references section is optional, especially if they are cited in a publication that explains the technical details (see section Technical Details).
175+
2. The references section should provide references of publications related to this method (e.g., in APA7 style, https://apastyle.apa.org/style-grammar-guidelines/references/examples).
176+
-->
71177

72178
<!-- ## Acknowledgements -->
73-
<!-- - Acknowledgements if any -->
179+
<!--
180+
1. The acknowledgments section is optional.
181+
2. The acknowledgments section should list expressions of gratitude to people or organizations who contributed, supported or guided.
182+
-->
183+
184+
<!-- ## Disclaimer-->
185+
<!--
186+
1. The disclaimer section is optional.
187+
2. The disclaimer section should list disclaimers, legal notices, or usage restrictions for the method.
188+
-->
189+
190+
## Contact Details
191+
<!--
192+
1. The contact details section should specify whom to contact for questions or contributions and how (can be separate entitites; for example email addresses or links to the GitHub issue board).
193+
-->
74194

75-
<!-- ## Disclaimer -->
76-
<!-- - Add any disclaimers, legal notices, or usage restrictions for the method, if necessary. -->
195+
Maintainer: David Schoch <[email protected]>
196+
197+
Issue Tracker: [https://github.com/schochastics/graphlayouts/issues](https://github.com/schochastics/graphlayouts/issues)

0 commit comments

Comments
 (0)