sf <- file(system.file("GXL/simpleExample.gxl", package="graph"))
show(fromGXL(sf))
print(dumpGXL(sf))
close(sf)
#validateGXL(sf)
# bad <- file(system.file("GXL/c2.gxl", package="graph"))
# here's how you can check if the GXL is well-formed, if
# you have a libxml2-based version of R XML package
#
# try( validateGXL(bad) )
#
gR <- graphNEL(nodes=letters[1:4], edgeL=list(
a=list(edges=4), b=list(edges=3), c=list(edges=c(2,1)), d=list(edges=1)),
edgemode="directed")
#
# following requires that you are using XML bound with recent libxml2
#
#an <- as.numeric
#if (an(libxmlVersion()$major)>=2 && an(libxmlVersion()$minor)>=4)
## since toGXL returns an XML object, we need to attach the XML
## package.
library("XML")
cat(saveXML(toGXL(gR)$value()))
wtd <- file(system.file("GXL/kmstEx.gxl", package="graph"))
wtdg <- fromGXL(wtd)
close(wtd)
print(edgeWeights(wtdg))
Run the code above in your browser using DataLab