2016-12-25 129 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