{
cytoscape.use(dagre);
var cy = cytoscape({
container: document.getElementById("myGraph"),
userZoomingEnabled: true,
elements: {
nodes: [
{ data: { id: "a", parent: "b", score: 3 } },
{ data: { id: "b", score: 5, weight: 10 } },
{ data: { id: "c", parent: "b", score: 1, weight: 10 } },
{ data: { id: "d", score: 4 } },
{ data: { id: "e", score: 0 } },
{ data: { id: "f", parent: "e" } }
],
edges: [
{
data: { id: "ac", source: "a", target: "c", score: 5, weight: 10 }
},
{ data: { id: "eb", source: "e", target: "b" } },
{ data: { id: "db", source: "d", target: "b" } }
]
},
layout: {
name: "dagre",
rows: 1
},
style: [
{
selector: "node",
style: {
"background-opacity": function (ele) {
return opacity(ele);
},
"background-color": function (ele) {
return color(ele);
},
width: function (ele) {
return nodeSize(ele);
},
height: function (ele) {
return nodeSize(ele);
},
label: "data(id)"
}
},
{
selector: ":parent",
style: {
"background-color": "blue",
"background-opacity": 0.5,
"z-compound-depth": "auto"
}
},
{
selector: "edge",
style: {
width: 3,
lineColor: function (ele) {
return color(ele);
},
targetArrowColor: function (ele) {
return color(ele);
},
targetArrowShape: "triangle",
curveStyle: "bezier"
}
}
]
});
}