gexf-writer
v0.1.2
Published
A simple GEXF format writer
Downloads
9
Maintainers
Readme
JavaScript GEXF Writer
Installation
With npm do:
$ npm install gexf-writer
Examples
Basic
var GexfWriter = require('gexf-writer');
var gw = new GexfWriter();
var doc = gw.createDocument({
type: 'directed',
attributes: {
foo: {
type: 'string',
default: 'foo default values'
}
}
});
doc
.addNode("1", "node label", {
foo: "val1",
bar: "val2"
})
.addNode("2", "node label 2")
.addEdge("edgeId", "1", "2");
console.log(doc.toString());
Output:
<?xml version="1.0" encoding="UTF-8"?>
<gexf xmlns="http://www.gexf.net/1.2draft" version="1.2">
<meta>
<creator>gexf-writer</creator>
<description>GEXF document generated by gexf-writer</description>
</meta>
<graph defaultedgetype="directed">
<nodes>
<node id="1" label="node label" />
<node id="2" label="node label 2" />
</nodes>
<edges>
<edge id="edgeId" source="1" target="2" />
</edges>
</graph>
</gexf>
Tests
With mocha do:
$ mocha