| Title: | Interactive Graph Layout Editor for Mixed Graphs |
|---|---|
| Description: | Provides an interactive interface to plot and layout mixed graphs based on the adjacency matrix defined in Sadeghi and Marchetti (2012) <doi:10.32614/RJ-2012-015>. Uses 'shiny' and 'visNetwork' to allow dynamic node repositioning and coordinate extraction. |
| Authors: | Giovanni M. Marchetti [aut, cre] (ORCID: <https://orcid.org/0000-0003-4413-9349>), Kayvan Sadeghi [aut] (ORCID: <https://orcid.org/0000-0001-7314-744X>) |
| Maintainer: | Giovanni M. Marchetti <[email protected]> |
| License: | GPL-2 |
| Version: | 0.1.0 |
| Built: | 2026-10-22 11:59:36 UTC |
| Source: | https://github.com/cran/ggmGraphEditor |
An interactive replacement for ggm::plotGraph using
shiny and visNetwork.
Allows dynamic node repositioning, handles multiple edge types,
and outputs node coordinates.
graphLayout( ggm_matrix, dashed = TRUE, bidirected_roundness = 0.25, Viewer = if (Sys.getenv("RSTUDIO") == "1") "Rstudio" else "browser" )graphLayout( ggm_matrix, dashed = TRUE, bidirected_roundness = 0.25, Viewer = if (Sys.getenv("RSTUDIO") == "1") "Rstudio" else "browser" )
ggm_matrix |
|
dashed |
Logical. If |
bidirected_roundness |
Numeric. Curvature of bidirected edges
when multiple edges are present. Default is |
Viewer |
character string specifying where to display the
Shiny application. Valid options are |
A matrix of X and Y coordinates for each node,
returned after terminating the Shiny application.
The author acknowledges the help of Google Gemini AI (2026).
Giovanni M. Marchetti
if (interactive()) { amat <- matrix(c(0,1,0, 0,0,1, 0,0,0), 3, 3, dimnames = list(c("A","B","C"), c("A","B","C"))) coords <- graphLayout(amat) print(coords) # Generating the adjacency matrix from a vector and plotting exvec <- c( "b", 1, 2, "b", 1, 14, "a", 9, 8, "l", 9, 11, "a", 10, 8, "a", 11, 2, "a", 11, 9, "a", 11, 10, "a", 12, 1, "b", 12, 14, "a", 13, 10, "a", 13, 12 ) graphLayout(exvec) # Plotting from a direct adjacency matrix amat2 <- matrix(c(0, 11, 0, 0, 10, 0, 100, 0, 0, 100, 0, 1, 0, 0, 1, 0), 4, 4) graphLayout(amat2) # A graph with double and triple edges G <- structure(c( 0, 101, 0, 0, 100, 0, 100, 100, 0, 100, 0, 100, 0, 111, 100, 0), dim = c(4L, 4L), dimnames = list(c("X", "Z", "Y", "W"), c("X", "Z", "Y", "W"))) graphLayout(G) # A graph with 4 edges between two nodes G4 <- matrix(0, 2, 2) G4[1, 2] <- 111 G4[2, 1] <- 111 graphLayout(G4) }if (interactive()) { amat <- matrix(c(0,1,0, 0,0,1, 0,0,0), 3, 3, dimnames = list(c("A","B","C"), c("A","B","C"))) coords <- graphLayout(amat) print(coords) # Generating the adjacency matrix from a vector and plotting exvec <- c( "b", 1, 2, "b", 1, 14, "a", 9, 8, "l", 9, 11, "a", 10, 8, "a", 11, 2, "a", 11, 9, "a", 11, 10, "a", 12, 1, "b", 12, 14, "a", 13, 10, "a", 13, 12 ) graphLayout(exvec) # Plotting from a direct adjacency matrix amat2 <- matrix(c(0, 11, 0, 0, 10, 0, 100, 0, 0, 100, 0, 1, 0, 0, 1, 0), 4, 4) graphLayout(amat2) # A graph with double and triple edges G <- structure(c( 0, 101, 0, 0, 100, 0, 100, 100, 0, 100, 0, 100, 0, 111, 100, 0), dim = c(4L, 4L), dimnames = list(c("X", "Z", "Y", "W"), c("X", "Z", "Y", "W"))) graphLayout(G) # A graph with 4 edges between two nodes G4 <- matrix(0, 2, 2) G4[1, 2] <- 111 G4[2, 1] <- 111 graphLayout(G4) }
grMAT2 converts graph objects to a mixed adjacency matrix.
grMAT2(agr)grMAT2(agr)
agr |
A graph object. This can be:
|
Support for graphNEL objects requires the graph package
from Bioconductor, which is a suggested dependency.
If the package is missing, passing a graphNEL object will
trigger an informative error.
A matrix consisting of 4 different integers
representing the -elements:
0 for a missing edge between and ,
1 for an arrow from to ,
10 for a full line between and , and
100 for a bi-directed arrow between and .
These numbers are added when multiple edges of different types
are present. The matrix is symmetric with respect to full lines
and bi-directed arrows.
Kayvan Sadeghi, Giovanni Marchetti
## Generating the adjacency matrix from a vector exvec <- c( "b", 1, 2, "b", 1, 14, "a", 9, 8, "l", 9, 11, "a", 10, 8, "a", 11, 2, "a", 11, 10, "a", 12, 1, "b", 12, 14, "a", 13, 10, "a", 13, 12) grMAT2(exvec) ## Example with graphNEL (requires the 'graph' package from Bioconductor) if (requireNamespace("graph", quietly = TRUE)) { V <- c("a", "b", "c") g <- graph::graphNEL(nodes = V, edgemode = "undirected") grMAT2(g) } g <- c("a", 3, 1, "l", 1, 2, "*", 4, 4) grMAT2(g)## Generating the adjacency matrix from a vector exvec <- c( "b", 1, 2, "b", 1, 14, "a", 9, 8, "l", 9, 11, "a", 10, 8, "a", 11, 2, "a", 11, 10, "a", 12, 1, "b", 12, 14, "a", 13, 10, "a", 13, 12) grMAT2(exvec) ## Example with graphNEL (requires the 'graph' package from Bioconductor) if (requireNamespace("graph", quietly = TRUE)) { V <- c("a", "b", "c") g <- graph::graphNEL(nodes = V, edgemode = "undirected") grMAT2(g) } g <- c("a", 3, 1, "l", 1, 2, "*", 4, 4) grMAT2(g)