| Type: | Package |
| Title: | Interactive Graph Layout Editor for Mixed Graphs |
| Version: | 0.1.0 |
| Depends: | R (≥ 3.6.0) |
| Imports: | methods, visNetwork, shiny, igraph |
| Suggests: | ggm (≥ 2.5.5), graph, testthat (≥ 3.0.0) |
| 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. |
| License: | GPL-2 |
| Encoding: | UTF-8 |
| URL: | https://github.com/StaThin/ggmGraphEditor |
| BugReports: | https://github.com/StaThin/ggmGraphEditor/issues |
| NeedsCompilation: | no |
| Config/roxygen2/version: | 8.1.0 |
| Config/testthat/edition: | 3 |
| Packaged: | 2026-10-08 12:48:35 UTC; gmm |
| Author: | Giovanni M. Marchetti
|
| Maintainer: | Giovanni M. Marchetti <giovanni.marchetti@unifi.it> |
| Repository: | CRAN |
| Date/Publication: | 2026-10-20 14:20:02 UTC |
Graph to adjacency matrix
Description
grMAT2 converts graph objects to a mixed adjacency matrix.
Usage
grMAT2(agr)
Arguments
agr |
A graph object. This can be:
|
Details
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.
Value
A matrix consisting of 4 different integers
representing the ij-elements:
0 for a missing edge between
iandj,1 for an arrow from
itoj,10 for a full line between
iandj, and100 for a bi-directed arrow between
iandj. 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.
Author(s)
Kayvan Sadeghi, Giovanni Marchetti
Examples
## 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)
Advanced Graph Layout Editor for Mixed Graphs
Description
An interactive replacement for ggm::plotGraph using
shiny and visNetwork.
Allows dynamic node repositioning, handles multiple edge types,
and outputs node coordinates.
Usage
graphLayout(
ggm_matrix,
dashed = TRUE,
bidirected_roundness = 0.25,
Viewer = if (Sys.getenv("RSTUDIO") == "1") "Rstudio" else "browser"
)
Arguments
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 |
Value
A matrix of X and Y coordinates for each node,
returned after terminating the Shiny application.
Note
The author acknowledges the help of Google Gemini AI (2026).
Author(s)
Giovanni M. Marchetti
Examples
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)
}