Javascript 细胞景观;根图;具有横向优先搜索布局
我在CytoscapeJs中寻找一个布局,它允许您插入一个根节点,并在深度2处放置所有具有指向它的直弧的节点,在深度3处放置具有与深度2处的直弧的节点,依此类推 我目前正在使用BFS,但正如您从图像中看到的那样,Sex=1和Pclass=3节点位于深度4,而我希望它们位于深度2(因为它们有一个直接的弧线指向SURVIED=1,即“根”) 您知道有一种布局可以对图形执行此操作,或者对breadfirstsearch进行哪些修改吗 代码:Javascript 细胞景观;根图;具有横向优先搜索布局,javascript,graph,layout,nodes,root,Javascript,Graph,Layout,Nodes,Root,我在CytoscapeJs中寻找一个布局,它允许您插入一个根节点,并在深度2处放置所有具有指向它的直弧的节点,在深度3处放置具有与深度2处的直弧的节点,依此类推 我目前正在使用BFS,但正如您从图像中看到的那样,Sex=1和Pclass=3节点位于深度4,而我希望它们位于深度2(因为它们有一个直接的弧线指向SURVIED=1,即“根”) 您知道有一种布局可以对图形执行此操作,或者对breadfirstsearch进行哪些修改吗 代码: var json_obj = response.Cy_j
var json_obj = response.Cy_json_archi_prima_di_chiusura_atk_supp
var cy = cytoscape({
container: document.getElementById('cy_atk_supp'),
elements: JSON.parse(json_obj),
style: [
{
selector: 'node',
style: {
'id' : 'data(id)',
'shape': 'circle',
'label': 'data(label)',
'text-valign': 'center',
'text-halign': 'center',
'color': 'black',
"height": 150,
"width": 150,
'border-width': '2px',
'border-color': 'black',
'background-color': '#399AF9',
'font-size': 35
}
},
{
selector: 'edge',
style:{
'label': 'data(weight)',
'border-width': '2px',
'border-color': 'black',
'color':'data(color)',
'font-size': 50,
'labelFontWeight': 'bold',
'lineColor': 'data(color)',
'width': 6,
'target-arrow-color': 'data(color)',
"curve-style": "bezier",
'target-arrow-shape': 'triangle',
}
}
],
layout: {
name: 'breadthfirst',
fit: true, // whether to fit the viewport to the graph
directed: true, // whether the tree is directed downwards (or edges can point in any direction if false)
padding: 30, // padding on fit
circle: false, // put depths in concentric circles if true, put depths top down if false
grid: false, // whether to create an even grid into which the DAG is placed (circle:false only)
spacingFactor: 1.75, // positive spacing factor, larger => more space between nodes (N.B. n/a if causes overlap)
boundingBox: undefined, // constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h }
avoidOverlap: true, // prevents node overlap, may overflow boundingBox if not enough space
nodeDimensionsIncludeLabels: false, // Excludes the label when calculating node bounding boxes for the layout algorithm
roots: "[id = '"+classe_scelta_da_utente+"']", // the roots of the trees
maximal: false, // whether to shift nodes down their natural BFS depths in order to avoid upwards edges (DAGS only)
animate: false, // whether to transition the node positions
animationDuration: 500, // duration of animation in ms if enabled
animationEasing: undefined, // easing of animation if enabled,
animateFilter: function ( node, i ){ return true; }, // a function that determines whether the node should be animated. All nodes animated by default on animate enabled. Non-animated nodes are positioned immediately when the layout starts
ready: undefined, // callback on layoutready
stop: undefined, // callback on layoutstop
transform: function (node, position ){ return position; } // transform a given node position. Useful for changing flow direction in discrete layouts
}
});