A very small module so you can stop thinking about certain repetetive
operations while managing d3js force directed graphs
Status is designed to work with d3, although it should work for anything which
imnplements a similar API, meaning the force argument has a
method which returns an incidince list of the edges in the graph. In any event,
you need a few things before we can et started:
var Status =d3 =/* A few parameters */var loops = false // node cannot link to itselfdirected = false // link from A to B == link from B to Amultiedge = false // at most one link between nodes A and B.var s = loops directed multiedgevar force = d3layout/* Supposing you've defined links and nodes somewhere. */forcelinkslinks_arrayvar one_link = // a linkanother_link = // another link/* start the layout -- this gives the nodes an index. although their positions* wont update until the first tick. */forcestart
Checking for equality will respect your settings:
A method to easily find the index of the link in the force. Mimics the api of Array#indexOf api.
There is a convenient membership check:
s // -> true or false
And finally a method to count the number of times a link appears (useful when
multiedge == true.
Is very short and available here