2016-12-25 53 views

回答

0

您是否尝试过的广度优先布局concentric选项?默认情况下,宽度优先给出金字塔式布局,但您可以指定圆形布局。

例如:

var cy = cytoscape({ 
    container: document.getElementById('cy'), 
    elements: { 
     nodes: [ 
     { data: { id: 'a' } }, 
     { data: { id: 'b' } }, 
     { data: { id: 'c' } }, 
     { data: { id: 'd' } }, 
     { data: { id: 'e' } } 
     ], 

     edges: [ 
     { data: { id: 'ae', weight: 1, source: 'a', target: 'e' } }, 
     { data: { id: 'ab', weight: 3, source: 'a', target: 'b' } }, 
     { data: { id: 'be', weight: 4, source: 'b', target: 'e' } }, 
     { data: { id: 'bc', weight: 5, source: 'b', target: 'c' } }, 
     { data: { id: 'ce', weight: 6, source: 'c', target: 'e' } }, 
     { data: { id: 'cd', weight: 2, source: 'c', target: 'd' } }, 
     { data: { id: 'de', weight: 7, source: 'd', target: 'e' } } 
     ] 
    }, 
    layout: { 
    name: 'breadthfirst', 
    circle: true, 
    root: 'a', 
    }, 
}); 

为我的代码的其余部分见https://jsfiddle.net/josephst18/kznos1x9/2/

+0

有人还通过基于'breadthfirst'的布局制作了一个PR,该布局具有DAG的循环功能。 @JALO - JusAnotherLivngOrganism如果你能够看看这个人制作的布局,并且可能将这些更改合并到“breadthfirst”布局中作为拉取请求,那将是非常好的:https://github.com/cytoscape/ cytoscape.js/pull/1617做这个公关的人没有做出适当的公关,只是在他的布局中加入了一些文本文件,现在我没有时间审查他的文件。 – maxkfranz