Graphical markov chain in javascript [closed]
Asked Answered
G

3

8

I have a Markov chain that I would like to represent graphically in javascript. I need to represent the nodes, links, and transition probabilities. Perhaps something like one of these two diagrams:

enter image description here enter image description here

Finding a good image library (like Raphael) is not the problem. The problem, for me, is finding a way to make sure the nodes are laid out nicely, with a minimal amount of lines crossing in front of other nodes or lines. Something like the "Lay out diagram" option in OmniGraffle (I'm sure there's a similar feature in Visio).

Is there a JS library that can do this for me, and if not does anyone have any idea how to approach a problem like this? Note that my markov chains are likely to be a lot more complex then the examples above.

Gregoriagregorian answered 25/8, 2011 at 3:6 Comment(3)
how did the project turn out?Feudality
@MichaelPaulukonis i ended up using graphdracula (see my comment to Femi's answer). It worked, but not quite as nice as I had hoped. There were some issues when a node points to itself, or when two nodes form a loop. The placement of the transition probabilities was sometimes unclear which line it belonged to. Still, I couldn't find anything better, so it made do.Gregoriagregorian
is your code available? I'd be interested in throwing some things at it to see what the chains look like (non-academically related).Feudality
B
3

You might make out okay with one of the directed graph libraries like D3 or one of the directed graph layers on Raphael.

Brokerage answered 25/8, 2011 at 3:17 Comment(3)
+1 on using Raphael. 2.0 is also on the way: github.com/DmitryBaranovskiy/raphael/tree/2.0Alisonalissa
Thanks! I guess it helps to know the right terminology-- googling "force directed graph" helped me find a few other alternatives as well, and graphdracula.net seems to fit my needs. thejit.org is another for those looking for alternatives.Gregoriagregorian
Hehe. Glad to help provide the right spell to insert into Google.Brokerage
V
2

I'm using mxGraph for this currently. It's not free, but it's a case of you get what you pay for.

Varied answered 23/1, 2013 at 12:10 Comment(0)
W
0

Viz.js can be used for this, it is a Javascript port of Graphviz.

Waltner answered 28/12, 2012 at 0:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.