5

I've been exploring the d3.js library, and especially the force directed graph creation. I perused the paper on it by Bostock et al, and noticed the precise type of graph I'm trying to create, basically a force directed graph with color coded regions surrounding groups of a feather.

It's the illustration on 3rd column, 2nd row, here, labelled "force-directed graph clusters": http://vis.stanford.edu/papers/d3

the code here generates the basic graph: http://mbostock.github.com/d3/ex/force.html

My question is: what is the code to dynamically generate the region polygons?

3 Answers 3

8

You could try integrating the example hull code with the force nodes.

Hull: http://bl.ocks.org/mbostock/4341699

Force Layout: http://bl.ocks.org/mbostock/1021841

This is the answer I provided in the comments:

http://bl.ocks.org/donaldh/2920551

Sign up to request clarification or add additional context in comments.

4 Comments

that, @donaldh, is definitely a push in the right directions... now only if i were a coder... i am a designer, could you suggest some more specific integration examples
I wanted to experiment with this myself so have hacked the force-multi-foci example to add a convex hull. http://bl.ocks.org/2918073. When I get a chance I will extend the example to create a path around each category of nodes.
Okay, here is v2 with a convex hull for each cluster of nodes. bl.ocks.org/2920551. bl.ocks.org seems to be down just now so here is the gist gist.github.com/2920551
Wow, Donald! That is PERFECT! amazing! awesome! THANK YOU!
4

See the force-cluster example in D3's repository.

3 Comments

Thanks Mike. I looked at that... that one has expandable circles representing the clusters. Is the code available to render the actual dynamic polygons as shown in the illustration?
link is now a 404. Could you fix it?
Here is a cluster force layout example
1

If you are referring to the code that creates the circular nodes in the graph:

 var node = svg.selectAll("circle.node") .data(json.nodes) .enter().append("circle") .attr("class", "node") .attr("r", 5) .style("fill", function(d) { return color(d.group); }) .call(force.drag); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.