a small toy to render graph with text
A simple toy to render a graph with text symbols.
This will render a 10x10 grid graph in your terminal:
var graph = require'ngraph.generators'grid10 10;var asciiGraphics = require'ngraph.ascii'graphicsgraph;asciiGraphicsrun;
You can also customize how each node is rendered, by passing a callback:
var graph = require'ngraph.generators'grid10 10;var asciiGraphics = require'../'graphicsgraph;asciiGraphicscreateNodeUIreturn '+'; // each node is now rendered as a '+' symbol;asciiGraphicsrun;
Even though the name says
ascii you can use unicode symbols if your terminal supports them:
Note: in these examples we are using
ngraph.generators to create a predefined graph.
You can always use ngraph.graph for custom graphs.
With npm do:
npm install ngraph.ascii