Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functionality to run a dot file through graphviz #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export(
makeNodeAttrs,
pieGlyph,
removedEdges,
toFile,
layoutGraph
)

Expand All @@ -69,7 +68,8 @@ exportClasses(
)

exportMethods(
graphDataDefaults,
toFile,
graphDataDefaults,
"graphDataDefaults<-",
graphData,
"graphData<-",
Expand Down
2 changes: 2 additions & 0 deletions R/AllGenerics.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ setGeneric("to", function(object) standardGeneric("to"))

setGeneric("toDot", function(graph, filename, ...) standardGeneric("toDot"))

setGeneric("toFile", function(graph, layoutType="dot", filename, fileType="dot") standardGeneric("toFile"))

###################################################################
# graph attributes
###################################################################
Expand Down
63 changes: 45 additions & 18 deletions R/writers.R
Original file line number Diff line number Diff line change
@@ -1,21 +1,48 @@
toFile <- function(graph, layoutType = "dot", filename, fileType = "dot") {
if ( !is(graph,"Ragraph") ) stop("Given graph is not of class Ragraph")

layoutType <- .checkLayoutType(layoutType)
fileType <- .checkFileType(fileType)
filename <- path.expand(filename)
if(!is.null(graphvizCapabilities()) &&
! fileType %in% graphvizCapabilities()$deviceTypes) {
warning("Graphviz does not support 'fileType'")
return(NULL)
}

.Call("Rgraphviz_toFile", graph,
as.character(layoutType),
as.character(filename),
as.character(fileType),
PACKAGE="Rgraphviz")
}
## function that writes out an Rgraph to a file through the graphviz rendering engines
setMethod("toFile", c("Ragraph"),
function(graph, layoutType = "dot", filename, fileType = "dot") {
if ( !is(graph,"Ragraph") ) stop("Given graph is not of class Ragraph")

layoutType <- .checkLayoutType(layoutType)
fileType <- .checkFileType(fileType)
filename <- path.expand(filename)
if(!is.null(graphvizCapabilities()) &&
! fileType %in% graphvizCapabilities()$deviceTypes) {
warning("Graphviz does not support 'fileType'")
return(NULL)
}

.Call("Rgraphviz_toFile", graph,
as.character(layoutType),
as.character(filename),
as.character(fileType),
PACKAGE="Rgraphviz")
})

## function that writes out a dot graph given as a character vector to a file
## through the graphviz rendering engine
setMethod("toFile", c("character"),
function(graph, layoutType = "dot", filename, fileType = "dot") {
layoutType <- .checkLayoutType(layoutType)
fileType <- .checkFileType(fileType)
filename <- path.expand(filename)

if(!is.null(graphvizCapabilities()) &&
! fileType %in% graphvizCapabilities()$deviceTypes) {
warning("Graphviz does not support 'fileType'")
return(NULL)
}

## now collapse the graph into a character vector of length 1
graph <- paste(graph, collapse="\n")

res <- .Call("Rgraphviz_dotToFile", as.character(graph),
as.character(layoutType),
as.character(filename),
as.character(fileType),
PACKAGE="Rgraphviz")
return(invisible(res))
})

setMethod("toDot", "graph", function(graph, filename, ...) {
z <- agopen(graph, name = "foo", ...)
Expand Down
287 changes: 287 additions & 0 deletions inst/GV/softwareGraph.gv
Original file line number Diff line number Diff line change
@@ -0,0 +1,287 @@
digraph "Software Graph" {
graph [ranksep="0.75", size="7.5,7.5"];
node [];
"past" [shape="plaintext", fontsize="16"];
"1978" [shape="plaintext", fontsize="16"];
"1980" [shape="plaintext", fontsize="16"];
"1982" [shape="plaintext", fontsize="16"];
"1983" [shape="plaintext", fontsize="16"];
"1985" [shape="plaintext", fontsize="16"];
"1986" [shape="plaintext", fontsize="16"];
"1987" [shape="plaintext", fontsize="16"];
"1988" [shape="plaintext", fontsize="16"];
"1989" [shape="plaintext", fontsize="16"];
"1990" [shape="plaintext", fontsize="16"];
"future" [shape="plaintext", fontsize="16"];
"C*" [shape="box"];
"DAG" [shape="box"];
"CSAS" [shape="box"];
"CIA" [shape="box"];
"CIA++" [shape="box"];
"APP" [shape="box"];
"DOT" [shape="box"];
"DIA" [shape="box"];
"libft" [shape="box"];
"Software IS" [shape="ellipse"];
"Adv. Software Technology" [shape="box"];
"SCCS" [shape="plaintext", fontsize="16"];
"make" [shape="plaintext", fontsize="16"];
"Bourne sh" [shape="plaintext", fontsize="16"];
"yacc" [shape="plaintext", fontsize="16"];
"cron" [shape="plaintext", fontsize="16"];
"Reiser cpp" [shape="plaintext", fontsize="16"];
"Cshell" [shape="plaintext", fontsize="16"];
"build" [shape="plaintext", fontsize="16"];
"vi" [shape="plaintext", fontsize="16"];
"emacs" [shape="plaintext", fontsize="16"];
"RCS" [shape="plaintext", fontsize="16"];
"<curses>" [shape="plaintext", fontsize="16"];
"SYNED" [shape="box"];
"IMX" [shape="box"];
"ksh" [shape="box"];
"IFS" [shape="box"];
"TTU" [shape="box"];
"nmake" [shape="box"];
"Peggy" [shape="box"];
"ncpp" [shape="box"];
"<curses-i>" [shape="box"];
"ksh-i" [shape="box"];
"PG2" [shape="box"];
"Ansi cpp" [shape="box"];
"fdelta" [shape="box"];
"3D File System" [shape="box"];
"nmake 2.0" [shape="box"];
"SBCS" [shape="box"];
"PAX" [shape="box"];
"ksh-88" [shape="box"];
"PEGASUS/PML" [shape="box"];
"backtalk" [shape="box"];
"SHIP" [shape="box"];
"Data Share" [shape="box"];
"ryacc" [shape="box"];
"Mosaic" [shape="box"];
"CoShell" [shape="box"];
"sfio" [shape="box"];
"IFS-i" [shape="box"];
"ML-X" [shape="box"];
"kyacc" [shape="box"];
"yeast" [shape="box"];
"Configuration Mgt" [shape="ellipse"];
"Architecture & Libraries" [shape="ellipse"];
"Process" [shape="ellipse"];
edge [];
"past" -> "1978" [];
"1978" -> "1980" [];
"1980" -> "1982" [];
"1982" -> "1983" [];
"1983" -> "1985" [];
"1985" -> "1986" [];
"1986" -> "1987" [];
"1987" -> "1988" [];
"1988" -> "1989" [];
"1989" -> "1990" [];
"1990" -> "future" [];
"C*" -> "CSAS" [];
"DAG" -> "DOT" [];
"DAG" -> "DIA" [];
"DAG" -> "Software IS" [];
"CSAS" -> "CIA" [];
"CIA" -> "CIA++" [];
"CIA" -> "DIA" [];
"CIA++" -> "Software IS" [];
"APP" -> "DIA" [];
"APP" -> "Software IS" [];
"DOT" -> "Software IS" [];
"DIA" -> "Software IS" [];
"libft" -> "Software IS" [];
"Software IS" -> "Adv. Software Technology" [];
"SCCS" -> "RCS" [];
"SCCS" -> "3D File System" [];
"SCCS" -> "nmake" [];
"make" -> "nmake" [];
"make" -> "build" [];
"Bourne sh" -> "Cshell" [];
"Bourne sh" -> "ksh" [];
"yacc" -> "ryacc" [];
"cron" -> "yeast" [];
"Reiser cpp" -> "ncpp" [];
"Cshell" -> "ksh" [];
"build" -> "nmake 2.0" [];
"vi" -> "<curses>" [];
"vi" -> "ksh" [];
"emacs" -> "ksh" [];
"RCS" -> "fdelta" [];
"RCS" -> "SBCS" [];
"<curses>" -> "<curses-i>" [];
"SYNED" -> "Peggy" [];
"IMX" -> "TTU" [];
"ksh" -> "nmake" [];
"ksh" -> "ksh-i" [];
"ksh" -> "ksh-88" [];
"IFS" -> "<curses-i>" [];
"IFS" -> "sfio" [];
"IFS" -> "IFS-i" [];
"TTU" -> "PG2" [];
"nmake" -> "ncpp" [];
"nmake" -> "3D File System" [];
"nmake" -> "nmake 2.0" [];
"nmake" -> "ksh" [];
"Peggy" -> "PEGASUS/PML" [];
"Peggy" -> "ryacc" [];
"ncpp" -> "Ansi cpp" [];
"<curses-i>" -> "fdelta" [];
"ksh-i" -> "ksh-88" [];
"PG2" -> "backtalk" [];
"Ansi cpp" -> "Configuration Mgt" [];
"fdelta" -> "SBCS" [];
"fdelta" -> "PAX" [];
"3D File System" -> "Configuration Mgt" [];
"nmake 2.0" -> "Configuration Mgt" [];
"nmake 2.0" -> "CoShell" [];
"SBCS" -> "Configuration Mgt" [];
"PAX" -> "SHIP" [];
"ksh-88" -> "Configuration Mgt" [];
"ksh-88" -> "Architecture & Libraries" [];
"ksh-88" -> "sfio" [];
"PEGASUS/PML" -> "ML-X" [];
"PEGASUS/PML" -> "Architecture & Libraries" [];
"backtalk" -> "Data Share" [];
"SHIP" -> "Configuration Mgt" [];
"Data Share" -> "Architecture & Libraries" [];
"ryacc" -> "kyacc" [];
"Mosaic" -> "Process" [];
"CoShell" -> "Configuration Mgt" [];
"CoShell" -> "Architecture & Libraries" [];
"sfio" -> "Architecture & Libraries" [];
"IFS-i" -> "Architecture & Libraries" [];
"ML-X" -> "Architecture & Libraries" [];
"kyacc" -> "Architecture & Libraries" [];
"yeast" -> "Process" [];
"Configuration Mgt" -> "Adv. Software Technology" [];
"Architecture & Libraries" -> "Adv. Software Technology" [];
"Process" -> "Adv. Software Technology" [];
subgraph "past" {
graph [rank="same"];
node [];
"past" [];
"SCCS" [];
"make" [];
"Bourne sh" [];
"yacc" [];
"cron" [];
edge [];
}
subgraph "1978" {
graph [rank="same"];
node [];
"1978" [];
"Reiser cpp" [];
"Cshell" [];
edge [];
}
subgraph "1980" {
graph [rank="same"];
node [];
"1980" [];
"build" [];
"emacs" [];
"vi" [];
edge [];
}
subgraph "1982" {
graph [rank="same"];
node [];
"1982" [];
"RCS" [];
"<curses>" [];
"IMX" [];
"SYNED" [];
edge [];
}
subgraph "1983" {
graph [rank="same"];
node [];
"1983" [];
"ksh" [];
"IFS" [];
"TTU" [];
edge [];
}
subgraph "1985" {
graph [rank="same"];
node [];
"1985" [];
"nmake" [];
"Peggy" [];
edge [];
}
subgraph "1986" {
graph [rank="same"];
node [];
"1986" [];
"C*" [];
"ncpp" [];
"ksh-i" [];
"<curses-i>" [];
"PG2" [];
edge [];
}
subgraph "1987" {
graph [rank="same"];
node [];
"1987" [];
"Ansi cpp" [];
"nmake 2.0" [];
"3D File System" [];
"fdelta" [];
"DAG" [];
"CSAS" [];
edge [];
}
subgraph "1988" {
graph [rank="same"];
node [];
"1988" [];
"CIA" [];
"SBCS" [];
"ksh-88" [];
"PEGASUS/PML" [];
"PAX" [];
"backtalk" [];
edge [];
}
subgraph "1989" {
graph [rank="same"];
node [];
"1989" [];
"CIA++" [];
"APP" [];
"SHIP" [];
"Data Share" [];
"ryacc" [];
"Mosaic" [];
edge [];
}
subgraph "1990" {
graph [rank="same"];
node [];
"1990" [];
"libft" [];
"CoShell" [];
"DIA" [];
"IFS-i" [];
"kyacc" [];
"sfio" [];
"yeast" [];
"ML-X" [];
"DOT" [];
edge [];
}
subgraph "future" {
graph [rank="same"];
node [];
"future" [];
"Adv. Software Technology" [];
edge [];
}
}
Loading