briatte / ggnet

Network visualization with ggplot2
https://briatte.github.io/ggnet/
194 stars 33 forks source link

Manual weighting? #8

Closed elbamos closed 9 years ago

elbamos commented 9 years ago

Is there a way, or would you consider adding a way, to set the weighting manually?

I'm trying to construct a network for twitter users who discuss a particular topic. I'd like to weight each node by the number of people who would see a broadcast from that node. In twitter-speak, that's the number of "followers." I could populate my graph with an edge for every follower. Then it would have 75,000 edges instead of 300, which would create a nasty subsetting problem. So instead I only keep data for edges between users who've commented on the topic, and I track each user's number of followers.

Make sense?

briatte commented 9 years ago

I'm not sure I've fully understood your data (it actually sounds like two-mode data to me), but what you want to do is already possible in a weird way:

See also this bit of code, which gives you the same flexibility. It's a lightweight version of the ggnet function. The manual weights are stored in q.

briatte commented 9 years ago

Hi @elbamos

I still don't understand exactly what your graph looks like, but if you want to size the nodes of a Twitter network by any numeric value, such as the number of followers of each node, tthe the ggnet2 function should be able to do exactly what you want:

ggnet2(net, size = your_vector_of_weights)

or

ggnet2(net, size = "a_numeric_vertex_attribute")

Have a look at the vignette, especially the part about node sizes. Hope this helps!

elbamos commented 9 years ago

That was from December! I ended up writing new code for visualizing networks using ggplot2, which is an accepted PR to ggally and will be in the next release. If you take a look at some of the examples included there, you'll see what I was trying to accomplish.

On Sep 5, 2015, at 7:51 AM, François Briatte notifications@github.com wrote:

Hi @elbamos

I still don't understand exactly what your graph looks like, but if you want to size the nodes of a Twitter network by any numeric value, such as the number of followers of each node, tthe the ggnet2 function should be able to do exactly what you want:

ggnet2(net, size = your_vector_of_weights) or

ggnet2(net, size = "a_numeric_vertex_attribute") Have a look at the vignette, especially the part about node sizes. Hope this helps!

— Reply to this email directly or view it on GitHub.

briatte commented 9 years ago

Alright. I guess you are referring to the ggnetworkmap function in the dev branch. Looks interesting!

elbamos commented 9 years ago

Look at the Dev branch of ggally

On Sep 5, 2015, at 12:08 PM, François Briatte notifications@github.com wrote:

Would you mind pointing me to the code that you've submitted?

— Reply to this email directly or view it on GitHub.