sna

Assign colors to communities in igraph

瘦欲@ 提交于 2021-02-10 20:08:16
问题 I am using the fastgreedy.community detection algorithm in igraph to produce communities in R. The code returns 12 communities, however they are difficult to indentify when plotting because it returns a plot with a limited number of colours. How can I plot this graph with tweleve distinct colours? l2 <- layout.fruchterman.reingold(largest.component) ebc.g05 <- fastgreedy.community(largest.component) plot(largest.component, layout=l2, vertex.color=membership(ebc.g05), vertex.size=2, vertex

Assign colors to communities in igraph

微笑、不失礼 提交于 2021-02-10 20:01:08
问题 I am using the fastgreedy.community detection algorithm in igraph to produce communities in R. The code returns 12 communities, however they are difficult to indentify when plotting because it returns a plot with a limited number of colours. How can I plot this graph with tweleve distinct colours? l2 <- layout.fruchterman.reingold(largest.component) ebc.g05 <- fastgreedy.community(largest.component) plot(largest.component, layout=l2, vertex.color=membership(ebc.g05), vertex.size=2, vertex

Weighted Bimodal Bipartite Graph Projection conserving original weights

我的梦境 提交于 2021-02-08 03:08:15
问题 I have a large ( 36k vertices, 50k edges ) weighted bimodal bipartite graph and I would like to generate a projection that not only count the neighbors like the default weighted implementation but also sum the weights on the edges. You can think of it as a bipartite graph containing black vertices and blue vertices, where I want to conserve the original graph weights when there are only blue vertices. The implementations I came across keep the orange value, I am interested on the red one (or

Weighted Bimodal Bipartite Graph Projection conserving original weights

泄露秘密 提交于 2021-02-08 03:05:24
问题 I have a large ( 36k vertices, 50k edges ) weighted bimodal bipartite graph and I would like to generate a projection that not only count the neighbors like the default weighted implementation but also sum the weights on the edges. You can think of it as a bipartite graph containing black vertices and blue vertices, where I want to conserve the original graph weights when there are only blue vertices. The implementations I came across keep the orange value, I am interested on the red one (or

How to set the resolution parameter for Louvain modularity in igraph?

风格不统一 提交于 2021-01-21 09:26:17
问题 is there a way to set the resolution parameter when using the function cluster_louvain to detect communities in igraph for R? It makes a lot of difference for the result, as this parameter is related to the hierarchical dissimilarity between nodes. Thank you. 回答1: The easiest way to do it is through the resolution package, available in this link https://github.com/analyxcompany/resolution It is based on this paper http://arxiv.org/pdf/0812.1770.pdf It pretty much has 2 functions cluster

How to construct an edgeliste from a list of visited places (effectively)?

邮差的信 提交于 2020-05-15 09:35:11
问题 My original data.table consists of three columns. site , observation_number and id . E.g. the following which is all the observations for id = z |site|observation_number|id |a | 1| z |b | 2| z |c | 3| z Which means that ID z has traveled from a to b to c . There is no fixed number of sites per id. I wish to transform the data to an edge list like this |from |to||id| |a | b| z | |b | c| z | mock data sox <- data.table(site = c('a','b','c','a','c','c','a','d','e'), obsnum =c(1,2,3,1,2,1,2,3,4),

用Scrapy抓取豆瓣小组数据(一)

谁都会走 提交于 2020-04-17 03:58:04
【推荐阅读】微服务还能火多久?>>> 最近在coursera.org(在线学习平台)上学SNA(Social Network Analysis,社交网络分析)。有兴趣的同学可以去看一眼: https://class.coursera.org/sna-002 /,课程讲的很有意思,等回头我上完全部课程打算再写下详细总结和思考。 为什么要抓取豆瓣小组数据? 课程要做一个带编程的final project,大概内容就是自己找一个网络数据集,然后按照课程中提供的方法进行分析。其实最难的部分是找数据,两种方法:自己抓,或者是找现成的。对于后者,国内有个叫 数据堂 的数据分享网站做的不错,上面有豆瓣,淘宝,微博等各种数据,不过有些数据需要收费;国外有个叫 Konect 的网站专注于复杂网络数据。 看了一圈现成的数据都不太满意,决定自己抓取了。目标锁定豆瓣小组,打算分析小组之间的互相联系。 如何用Scrapy抓取网页? 还不太了解Scrapy的同学直接看这里 http://www.oschina.net/p/scrapy ,这边就不赘述基本功能和安装方式。 1,先建立一个scrapy项目,项目名称doubanscrapy startproject douban scrapy startproject douban 会生成一个项目目录,内部结构大概如下: douban/ scrapy.cfg ==

用Scrapy抓取豆瓣小组数据(二)

佐手、 提交于 2020-04-17 03:34:29
【推荐阅读】微服务还能火多久?>>> 接着上篇博客《用Scrapy抓取豆瓣小组数据(一)》 http://my.oschina.net/chengye/blog/124157 在scrapy中怎么让Spider自动去抓取豆瓣小组页面 1,引入Scrapy中的另一个预定义的蜘蛛CrawlSpider from scrapy.contrib.spiders import CrawlSpider, Rule from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor 2, 基于CrawSpider定义一个新的类GroupSpider,并添加相应的爬行规则。 class GroupSpider(CrawlSpider): name = "Group" allowed_domains = ["douban.com"] start_urls = [ "http://www.douban.com/group/explore?tag=%E8%B4%AD%E7%89%A9", "http://www.douban.com/group/explore?tag=%E7%94%9F%E6%B4%BB", "http://www.douban.com/group/explore?tag=%E7%A4%BE%E4%BC%9A", "http

Transform attribute vector into a matrix with differences of elements

*爱你&永不变心* 提交于 2020-01-25 23:39:07
问题 Similarly to this previous post I need to transfrom an attribute vector into a matrix. This time with differences between pairs of elements using R. For example I have a vector which reports the age of N people (from 18 to 90 years). I need to convert this vector into a NxN matrix named A (with people names on rows and columns), where each cell Aij has the value of |age_i-age_j|, representing the absolute difference in age between the two people i and j. Here is an example with 3 persons,

igraph edge between two vertices

杀马特。学长 韩版系。学妹 提交于 2020-01-23 02:54:06
问题 I'm new to R and igraph and I was wondering if anybody can help me with the following. I want to find the edge weight between two vertices in a graph. My graph structure is defined by the normal ego (node1), alter (node2) and the weight of the edge between them. I know that I can get the weight for each of the edges in the list of edges that originate from node number 5 using E(igraph_friendship) [ from(5) ]$weight And that I can find the weight for each of the edges in the list of edges that