Published
Edited
Feb 8, 2019
1 fork
Importers
Insert cell
Insert cell
Insert cell
Insert cell
// Create a new directed graph
graph = {
const g = new dagre.graphlib.Graph();

// Set an object for the graph label
g.setGraph({});

// Default to assigning a new object as a label for each new edge.
g.setDefaultEdgeLabel(function() { return {}; });

// Add nodes to the graph. The first argument is the node id. The second is
// metadata about the node. In this case we're going to add labels to each of
// our nodes.
g.setNode("kspacey", { label: "Kevin Spacey", width: 144, height: 100 });
g.setNode("rwright", { label: "Robin Wright", width: 144, height: 100 });
g.setNode("bpitt", { label: "Brad Pitt", width: 108, height: 100 });
g.setNode("hford", { label: "Harrison Ford", width: 168, height: 100 });
g.setNode("sweaver", { label: "Sigourney Weaver", width: 168, height: 100 });
g.setNode("kbacon", { label: "Kevin Bacon", width: 121, height: 100 });

// Add edges to the graph.
g.setEdge("kspacey", "rwright");
g.setEdge("rwright", "kbacon");
g.setEdge("bpitt", "kbacon");
g.setEdge("hford", "sweaver");
g.setEdge("sweaver", "kbacon");
return g;
}
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more