2012-09-30 5 views
1

아버 js를 사용하여 힘 기반 알고리즘을 사용하여 다이어그램을 만듭니다.아버 js - 그래프 저장 및로드

전체 에너지가 특정 지점보다 낮아진 후에 노드의 x, y 시스템 좌표를 저장할 수 있기를 바래서 그래프에 액세스 할 때 다시로드 할 필요가 없도록 다시로드하지 않아도됩니다. - 처음부터 모든 에너지를 처리하십시오.

  1. sys.energy().sum 항상 주어진 시간 후 그래프 노드 위치를 저장 setTimeout를 사용하는 나는 결정의 대안으로 NaN

    • 를 반환

      나는 두 가지 문제가이 일을 있었다 경과 된

  2. 나는 노드 x, y 시스템 좌표를 DB로 저장하면 저장된 x 좌표와 함께 그래프에 데이터를로드하려고 할 때 (sys.merge 또는 sys.addNode) 그래프가 표시되지 않고 '메모리 부족'메시지가 콘솔 로그에 표시됩니다. 여기

은 노드 X, 저장된 Y 시스템 좌표 데이터의 일례이며, 이는 어느 로딩 충돌 아버 JS 발생 :

{"nodes":{"0":{"edgeCount":0,"x":13.11901,"y":14.89151,"id":0,"name":"Global"},"23": 

{"edgeCount":1,"x":18.08981,"y":-0.8355745,"id":23,"name":"Aristotle"},"26": 
{"edgeCount":1,"x":5.688836,"y":14.86863,"id":26,"name":"Socrates"},"27": 
{"edgeCount":1,"x":14.84461,"y":-1.687457,"id":27,"name":"Christianity"},"34": 
{"edgeCount":1,"x":-2.265221,"y":13.59168,"id":34,"name":"Maths"},"91": 
{"edgeCount":11,"x":5.868572,"y":-1.315289,"id":91,"name":"Plato"},"92": 
{"edgeCount":4,"x":-3.14131,"y":8.81194,"id":92,"name":"Virtue"},"127": 
{"edgeCount":1,"x":-3.308347,"y":8.463552,"id":127,"name":"Poetry"},"131": 
{"edgeCount":1,"x":7.605158,"y":-3.951363,"id":131,"name":"Wisdom"},"147": 
{"edgeCount":1,"x":6.195698,"y":-4.572639,"id":147,"name":"Person"},"149": 
{"edgeCount":1,"x":2.10395,"y":-2.390886,"id":149,"name":"Republic"},"171": 
{"edgeCount":1,"x":3.359434,"y":-3.996424,"id":171,"name":"Justice"},"172": 
{"edgeCount":1,"x":-0.2544371,"y":-4.218832,"id":172,"name":"Temperance"},"173": 
{"edgeCount":1,"x":-8.773163,"y":2.587845,"id":173,"name":"Courage"},"178": 
{"edgeCount":1,"x":-2.380451,"y":-5.787674,"id":178,"name":"Schopenhauer"},"194": 
{"edgeCount":2,"x":-7.747643,"y":-1.653015,"id":194,"name":"Beauty"},"195": 
{"edgeCount":1,"x":-10.45985,"y":-2.670299,"id":195,"name":"Objective"},"196": 
{"edgeCount":1,"x":-10.64573,"y":-6.874766,"id":196,"name":"Truth"},"219": 
{"edgeCount":1,"x":-6.22574,"y":-7.565969,"id":219,"name":"Theory of forms"},"221": 
{"edgeCount":1,"x":-8.314561,"y":-7.570002,"id":221,"name":"Platinus"},"245": 
{"edgeCount":0,"x":-13.20351,"y":-8.421284,"id":245,"name":"Diagram"},"254": 
{"edgeCount":1,"x":-13.54734,"y":-7.7437,"id":254,"name":"Green"}}, 
    "edges":{"23":{"91":{"context":{"id":0,"name":"Global"},"source": 
{"id":23,"name":"Aristotle"},"predicate":{"id":21,"name":"studied with"},"target": 
{"id":91,"name":"Plato"}}},"26":{"91":{"context":{"id":0,"name":"Global"},"source": 
{"id":26,"name":"Socrates"},"predicate":{"id":2,"name":"inspires"},"target": 
{"id":91,"name":"Plato"}}},"91":{"149":{"context":{"id":0,"name":"Global"},"source": 
{"id":91,"name":"Plato"},"predicate":{"id":1,"name":"writes"},"target": 
{"id":149,"name":"Republic"}},"219":{"context":{"id":0,"name":"Global"},"source": 
{"id":91,"name":"Plato"},"predicate":{"id":1,"name":"writes"},"target":{"id":219,"name":"Theory of forms"}},"27":{"context":{"id":0,"name":"Global"},"source":{"id":91,"name":"Plato"},"predicate": 
{"id":3,"name":"influences"},"target":{"id":27,"name":"Christianity"}},"178":{"context": 
{"id":0,"name":"Global"},"source":{"id":91,"name":"Plato"},"predicate": 
{"id":3,"name":"influences"},"target":{"id":178,"name":"Schopenhauer"}},"221":{"context": 
{"id":0,"name":"Global"},"source":{"id":91,"name":"Plato"},"predicate": 
{"id":3,"name":"influences"},"target":{"id":221,"name":"Platinus"}},"254":{"context": 
{"id":245,"name":"Diagram"},"source":{"id":91,"name":"Plato"},"predicate": 
{"id":28,"name":"is"},"target":{"id":254,"name":"Green"}},"34":{"context": 
{"id":0,"name":"Global"},"source":{"id":91,"name":"Plato"},"predicate":{"id":33,"name":"is associated with"},"target":{"id":34,"name":"Maths"}},"127":{"context": 
{"id":0,"name":"Global"},"source":{"id":91,"name":"Plato"},"predicate":{"id":47,"name":"is obsessed with"},"target":{"id":127,"name":"Poetry"}},"147":{"context": 
{"id":0,"name":"Global"},"source":{"id":91,"name":"Plato"},"predicate":{"id":56,"name":"is type of"},"target":{"id":147,"name":"Person"}}},"92":{"131":{"context":{"id":91,"name":"Plato"},"source": 
{"id":92,"name":"Virtue"},"predicate":{"id":28,"name":"is"},"target": 
{"id":131,"name":"Wisdom"}},"171":{"context":{"id":91,"name":"Plato"},"source": 
{"id":92,"name":"Virtue"},"predicate":{"id":28,"name":"is"},"target": 
{"id":171,"name":"Justice"}},"172":{"context":{"id":91,"name":"Plato"},"source": 
{"id":92,"name":"Virtue"},"predicate":{"id":28,"name":"is"},"target": 
{"id":172,"name":"Temperance"}},"173":{"context":{"id":91,"name":"Plato"},"source": 
{"id":92,"name":"Virtue"},"predicate":{"id":28,"name":"is"},"target": 
{"id":173,"name":"Courage"}}},"194":{"195":{"context":{"id":91,"name":"Plato"},"source": 
{"id":194,"name":"Beauty"},"predicate":{"id":28,"name":"is"},"target": 
{"id":195,"name":"Objective"}},"196":{"context":{"id":91,"name":"Plato"},"source": 
{"id":194,"name":"Beauty"},"predicate":{"id":33,"name":"is associated with"},"target": 
{"id":196,"name":"Truth"}}}}} 

내가 그래프의 어떤 실시 예를 찾을 수 없다 노드 x, y 좌표는 입력 데이터에 있습니다.

답변

0

https://github.com/samizdatco/arbor/blob/master/src/physics/system.js#L83에서 보면 x 및 y 값을 데이터 사전에 포함시켜야합니다. 나는 여러분의 예제에서 데이터를 메서드에 전달하는 방법을 잘 모르겠습니다. 어쩌면 노드 몇 개를 추가하고 노드가 배치 된 위치를 확인해보십시오. 나는 NaN 인 에너지에 동일한 문제가 있습니다. 아마도 디버거를 사용하면 도움이 될 것입니다.