thechiselgroup / biomixer

BioMixer
http://bio-mixer.appspot.com/
16 stars 13 forks source link

Force Tweaks #445

Open everbeek opened 9 years ago

everbeek commented 9 years ago

Try these to see if they improve force layout behavior: -use locus in center to control overall force position -increase weights on inheritance, slightly on composition, lowest for mapping.

https://github.com/mbostock/d3/wiki/Force-Layout#linkStrength

The force.linkStrength parameter to the layout can be a function, which would be applied to each edge. This is how we would modulate the inheritance, composition, property relation and mapping arc strengths. Alternatively, the force.theta property is a global node repulsion parameter, and this could also get the desired effect. It is implemented in an efficient way, n*log(n), but we'd have to see how it ran.

I hope that linkStrength changes will cause nodes in the following export data to be laid out without throwing parallel series of inheritance and composition arcs together, and thus not putting lots of nodes into the same space. The export is produced from an Eye Part concept expansion on this base graph: http://127.0.0.1:8888/conceptPathToRoot.html?gwt.codesvr=127.0.0.1:9997&initial_vis=term_neighborhood&ontology_acronym=SNOMEDCT&full_concept_id=http%3A%2F%2Fpurl.bioontology.org%2Fontology%2FSNOMEDCT%2F81745001

{"NB":"Greetings! This is a BioMixer portable graph. Paste this entire data structure into the Import dialog box, accessible via the menu. Use the url: http://127.0.0.1:8888/conceptPathToRoot.html .","n":{"http://purl.bioontology.org/ontology/SNOMEDCT/119263007":{"o":"SNOMEDCT","x":484.7536376435065,"y":292.75576437860855},"http://purl.bioontology.org/ontology/SNOMEDCT/280536008":{"o":"SNOMEDCT","x":731.8511955951805,"y":40.78807786317153},"http://purl.bioontology.org/ontology/SNOMEDCT/86588008":{"o":"SNOMEDCT","x":596.9075729723552,"y":644.1033664472164},"http://purl.bioontology.org/ontology/SNOMEDCT/40049005":{"o":"SNOMEDCT","x":586.812316113568,"y":638.052600394255},"http://purl.bioontology.org/ontology/SNOMEDCT/371398005":{"o":"SNOMEDCT","x":730.9146797912109,"y":326.18089112343847},"http://purl.bioontology.org/ontology/SNOMEDCT/5979006":{"o":"SNOMEDCT","x":322.46583937976453,"y":605.903824431125},"http://purl.bioontology.org/ontology/SNOMEDCT/281831001":{"o":"SNOMEDCT","x":900.5509863101985,"y":640.3574408339277},"http://purl.bioontology.org/ontology/SNOMEDCT/392406005":{"o":"SNOMEDCT","x":555.465830879449,"y":648.1077895027685},"http://purl.bioontology.org/ontology/SNOMEDCT/399577003":{"o":"SNOMEDCT","x":185.18031952888327,"y":467.9166203357936},"http://purl.bioontology.org/ontology/SNOMEDCT/302151004":{"o":"SNOMEDCT","x":561.3985514372584,"y":633.2918150935783},"http://purl.bioontology.org/ontology/SNOMEDCT/399685002":{"o":"SNOMEDCT","x":235.97146701825778,"y":538.2161086364916},"http://purl.bioontology.org/ontology/SNOMEDCT/8966001":{"o":"SNOMEDCT","x":339.6516286007985,"y":346.06083830373217},"http://purl.bioontology.org/ontology/SNOMEDCT/76729009":{"o":"SNOMEDCT","x":579.4852176838036,"y":644.1432512963013},"http://purl.bioontology.org/ontology/SNOMEDCT/38881003":{"o":"SNOMEDCT","x":715.3460496157488,"y":36.744235076363246},"http://purl.bioontology.org/ontology/SNOMEDCT/244486005":{"o":"SNOMEDCT","x":832.8357092969849,"y":384.97328723353166},"http://purl.bioontology.org/ontology/SNOMEDCT/8264007":{"o":"SNOMEDCT","x":589.7957950919242,"y":646.5641098794983},"http://purl.bioontology.org/ontology/SNOMEDCT/314859006":{"o":"SNOMEDCT","x":611.4366758169982,"y":647.6478509190935},"http://purl.bioontology.org/ontology/SNOMEDCT/305092003":{"o":"SNOMEDCT","x":739.6510761752668,"y":42.89154858753482},"http://purl.bioontology.org/ontology/SNOMEDCT/18944008":{"o":"SNOMEDCT","x":513.26897622101,"y":277.5625404975498},"http://purl.bioontology.org/ontology/SNOMEDCT/91717005":{"o":"SNOMEDCT","x":653.3456006601353,"y":609.6081192956527},"http://purl.bioontology.org/ontology/SNOMEDCT/81745001":{"o":"SNOMEDCT","x":544.6400223578296,"y":635.4059155286762},"http://purl.bioontology.org/ontology/SNOMEDCT/79652003":{"o":"SNOMEDCT","x":748.1640424446546,"y":45.304828790293556},"http://purl.bioontology.org/ontology/SNOMEDCT/119258008":{"o":"SNOMEDCT","x":568.7189378721384,"y":636.4996950767048},"http://purl.bioontology.org/ontology/SNOMEDCT/399700002":{"o":"SNOMEDCT","x":375.1009062798188,"y":629.5744641715548},"http://purl.bioontology.org/ontology/SNOMEDCT/280539001":{"o":"SNOMEDCT","x":575.9240546883144,"y":636.8679758630656},"http://purl.bioontology.org/ontology/SNOMEDCT/302548004":{"o":"SNOMEDCT","x":894.6427584933424,"y":651.880632684614},"http://purl.bioontology.org/ontology/SNOMEDCT/80973000":{"o":"SNOMEDCT","x":603.6256976529457,"y":646.0024082423824},"http://purl.bioontology.org/ontology/SNOMEDCT/399748001":{"o":"SNOMEDCT","x":270.85361427413,"y":570.9001366075493},"http://purl.bioontology.org/ontology/SNOMEDCT/74862005":{"o":"SNOMEDCT","x":724.0520522249643,"y":38.76305235520111}},"s":{"inheritanceStyleLink":"rgb(0, 34, 102)","compositionStyleLink":"rgb(0, 51, 17)","mappingStyleLink":"rgb(212, 212, 212)"}}
everbeek commented 9 years ago

The linkStrength does not seem to have any effect.

I looked again at the collision detection example, in three browsers. In Chrome and IE, it runs rather quickly, but in Firefox, there is an open bug regarding SVG rendering, which hasn't quite been fixed yet. There are indications it will be fixed soon though. The example has more nodes than we generally would have, so if that example works swiftly, we could probably use that approach to deal with nodes overlapping due to arc pressure.

http://bl.ocks.org/mbostock/1748247

Ok, I just checked my FF verison, and went from 33.x to 34, and it has dramatically sped up SVG rendering! I feel like I have entered the future.

I should test this example with IE 9 as well though (25% of IE users; another 20% use IE8 which does not support SVG anyway; Chrome and FF users have a strong tendency to upgrade in a fairly timely fashion, so they would receive fine performance with collisions). Testing with IE11 emulation shows 8 to fail, and IE9 and also 10 to do fine, but do I trust that they are actually using SVG engines that would be used in the wild? I should use a Win7 VM to test this out, as it seems to be the only honest way to test it.

I have a virtual machine with IE10 running...that was acceptable. I need to get an image with IE9 on it though.

Tried IE9, and performance seems acceptable to me. I shall try setting up collision detection again.

everbeek commented 9 years ago

I think I am close to having the quadtree collision detection working, but my current problem is that points are considered rather than shapes. So if the centers of two nodes are not close enough to one another, then they will not be allowed into my code that checks their offsets from each other. I am confirming that this is the case, then figuring out how to get it working from here.

everbeek commented 9 years ago

It's too twitchy, because the collision displacement is immediately fought by the link rigidty. I played with parameters and it didn't help.

I am looking at charge again, but I don't know what will come of it.

everbeek commented 9 years ago

Well...I decided to plop Bostock's circular node version into what I had, and to ignore the fact I have rectangles...and it is working really well. I am going to clean things up, and commit this. It is easy to turn off. I shall also disable charge, since that apparently internally deals with another quadtree.

The circular one that seems to work is at: http://bl.ocks.org/mbostock/1748247 The rectangular one that I didn't get working is at: http://bl.ocks.org/ilyabo/2585241

Related: http://bl.ocks.org/eweitnauer/6941997 http://bl.ocks.org/mbostock/4343214 http://jimkang.com/quadtreevis/ http://bl.ocks.org/patricksurry/6478178 http://bl.ocks.org/eweitnauer/6941997

everbeek commented 9 years ago

Here is a typical outcome of collision detection, and a typical outcome without. There's no sense of modularity in either, but at least the nodes are not all attempting to cluster on top of one another.

typical collide typical pre-collide

everbeek commented 9 years ago

I am not entirely satisfied with the collision result. The layout is extremely disorganized.

Adding a gravitational bias within cliques would help. Is there an easier less structured way? Gravity equation that attracts nodes that are connected perhaps (still fought by link strength)? That would produce gravitational clusters out of cliques without having to analyze the graph...

everbeek commented 9 years ago

I should really try to get the collisions to respect the rectangles. It would surely increase layout quality.

everbeek commented 9 years ago

Aha! The concept layouts file has a charge setting in it. This was probably clobbering my changes elsewhere. I will give that a shot again.

Ok, so setting charge from -30 or -100 to -500, better still to -800, creates behavior comparable to that of the collision version, but still allows overlap frequently. It is smoother though...