sna

R - Matching rows and colums of matrices with different length

感情迁移 提交于 2019-12-06 10:28:02
问题 my problem at the moment is the following. I have an directed 1-mode edgelist representing pairs of actors participating in joint projects in a certain year, which might look like: projektleader projectpartner year A B 2005 A C 2000 B A 2002 ... ... ... Now I need only a subset for one particular year. Not all actors are active in very year, so the dimensions of the subsets differ. For a following Network Analysis, I need a weighted and directed adjacency matrix, so I use the option of the

converting data frame into affiliation network in R

一个人想着一个人 提交于 2019-12-05 18:23:48
I have a data frame with the following format: name workplace a A b B c A d C e D .... I would like to convert this data frame into an affiliation network in R with the format A B C D ... a 1 0 0 0 b 0 1 0 0 c 1 0 0 0 d 0 0 1 0 e 0 0 0 1 ... and I used the following program: for (i in 1:nrow(A1)) { a1[rownames(a1) == A1$name[i], colnames(a1) == A1$workplace[i]] <- 1 } where A1 is the data frame, and a1 is the affiliation network. However, since I have a large data frame, the above program runs very slow. Is there an efficient way that avoids looping in data conversion? Thank you very much! If

Python 2.7 NetworkX (Make it interactive)

邮差的信 提交于 2019-12-04 04:05:33
I am new to NetworkX. Right now, I manage to connect all the nodes to this particular node. What I want to do next it to make it interactive e.g. able to make each of the node move by dragging using cursor. I know I have to make use of matplotlib, but I am not sure how to use it. Can anyone help me? My codes are: import matplotlib.pyplot as plt import networkx as nx import itertools d = [name of nodes] f = [number per nodes] for i in d: G.add_edge('"' + i + '"',b) pos=nx.fruchterman_reingold_layout(G, k=0.5, iterations=5) nx.draw_networkx_nodes(G,pos,node_size=130, node_color="white") nx.draw

Silverlight Path is blurry - How to snap to pixels?

匿名 (未验证) 提交于 2019-12-03 01:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a Canvas onto which I draw a Path : Even though the StrokeThickness is set to 1, the vertical part of the path is drawn across 2 pixels and in a lighter color. I know that WPF has the SnapsToDevicePixels property that would fix it, and I read that in Silverlight there is a UseLayoutRounding property that you can use in some cases to have the same effect, however it does not seem to apply to Path . Is there anything I can do to get that line drawn properly? 回答1: There is a pixel snapper class over at MSDN on Dave Relyea's Silverlight

APP 反馈的三种形式:toast、snackbar、dialog

感情迁移 提交于 2019-12-01 15:21:06
APP 反馈的三种形式:toast、snackbar、dialog 聪明的产品会在恰当的时间给予恰当的反馈,不反馈、反馈不及时、反馈不对都会让用户反感你的产品,从而失去用户。 现在的公司是做软硬件一体化,我负责OS层面的交互方案,这里会遇到要制定一些设计原则,从而让产品体验更统一。我们都知道,针对信息提醒,有一种设计形式叫toast,如何对toast进行规范,引发了我写这篇文章。 1.反馈 互联网产品存在两套反馈机制,一套是有明显界面变动的反馈,例如你点击淘宝列表页,立马就进入了商品详情页,页面的及时跳转是明显的视觉反馈;再比如你输入完账号密码,点击登录,登录成功,并进入了APP首页,这也是很明显的视觉反馈。 但,如果某种反馈不明显该怎么办?例如,你登录的时候你输错了账号密码,点击登录,是进入不了APP的,这个时候大部分产品都会给予toast提示用户:密码或账号输入错误,请重试。你看到这个提示之后,就会知道自己改怎么做了。这就是反馈的第二套机制:通过设计不同的形式来提示用户。 常见的反馈有三种样式:toast、snackbar、dialog。 2.Toast toast属于一种轻量级的反馈,常常以小弹框的形式出现,一般出现1到2秒会自动消失,可以出现在屏幕上中下任意位置,但同个产品会模块尽量使用同一位置,让用户产生统一认知。 在样式上,尽量和产品整体风格保持一致,这样会更和谐

Generating an edge list from ID and grouping vectors

萝らか妹 提交于 2019-12-01 09:20:29
I have a data frame of 205,000+ rows formatted as follows: df <- data.frame(project.id = c('SP001', 'SP001', 'SP001', 'SP017', 'SP018', 'SP017'), supplier.id = c('1224', '5542', '7741', '1224', '2020', '9122')) In the actual data frame there are 6700+ unique values of project.id . I would like to create an edge list that pairs suppliers who have worked on the same project. Desired end result for project.id = SP001 : to from 1224 5542 1224 7741 5542 7741 So far I've tried using split to create a list by project.id and then running lapply+combn to generate all possible combinations of supplier

Generating an edge list from ID and grouping vectors

我怕爱的太早我们不能终老 提交于 2019-12-01 06:40:32
问题 I have a data frame of 205,000+ rows formatted as follows: df <- data.frame(project.id = c('SP001', 'SP001', 'SP001', 'SP017', 'SP018', 'SP017'), supplier.id = c('1224', '5542', '7741', '1224', '2020', '9122')) In the actual data frame there are 6700+ unique values of project.id . I would like to create an edge list that pairs suppliers who have worked on the same project. Desired end result for project.id = SP001 : to from 1224 5542 1224 7741 5542 7741 So far I've tried using split to create

Format for importing edgelist into igraph in python

社会主义新天地 提交于 2019-11-30 18:39:38
问题 What is the edgelist format accepted by igraph for import into python? What should the textfile that contains my weighted edges look like? I've used igraph with R before, but don't have a working R installation on the machine I need to use---so I'm stuck in python. I have an egelist.txt something like this: 123123, 321321, 1 222222, 333333, 2 123123, 333333, 3 222222, 321321, 4 ...where the values are in (source, target, weight) form. How would I import this in python? Or should I reformat my

How to create weighted adjacency list/matrix from edge list?

倖福魔咒の 提交于 2019-11-28 17:07:05
My problem is very simple: I need to create an adjacency list/matrix from a list of edges. I have an edge list stored in a csv document with column1 = node1 and column2 = node2 and I would like to convert this to a weighted adjacency list or a weighted adjacency matrix. To be more precise, here's how the data looks like -where the numbers are simply node ids: node1,node2 551,548 510,512 548,553 505,504 510,512 552,543 512,510 512,510 551,548 548,543 543,547 543,548 548,543 548,542 Any tips on how to achieve the conversion from this to a weighted adjacency list/matrix? This is how I resolved to

How to create weighted adjacency list/matrix from edge list?

感情迁移 提交于 2019-11-27 10:03:20
问题 My problem is very simple: I need to create an adjacency list/matrix from a list of edges. I have an edge list stored in a csv document with column1 = node1 and column2 = node2 and I would like to convert this to a weighted adjacency list or a weighted adjacency matrix. To be more precise, here's how the data looks like -where the numbers are simply node ids: node1,node2 551,548 510,512 548,553 505,504 510,512 552,543 512,510 512,510 551,548 548,543 543,547 543,548 548,543 548,542 Any tips on