当前位置:网站首页>From spark csc. csr_ Matrix generate adjacency matrix
From spark csc. csr_ Matrix generate adjacency matrix
2022-07-06 19:36:00 【NorburyL】
need photo.edglist and cs.edglist
solution1
By output str, and str Operation filtering of .
result
fail, Unable to obtain data completely , There are too many link nodes in some nodes , I can't show it .
code
import scipy
from edglist_utils import load_network_data
from scipy import sparse
network_file = 'photo'
adj, features, Y = load_network_data('graphsage/input/' + network_file + '.mat')
f2 = open("graphsage/cora_adj_list.txt", 'w')
f1 = open("graphsage/cora_create_list.txt", 'w')
# for i in range(2708):
# f2.write(str(i) + "\n" + str(adj[i]) + "\n\n")
# for part in adj[i]:
#
#
# part = str(part).replace(' (0, ', '')
# part = str(part).replace(') 1', '')
# part = str(part).replace(' : :\n', '')
# # list_str = list(str(part)) # Convert string to list
# # print(str(i)+","+part)
# quote_list = part.split('\n')
# for quote in quote_list:
# if (i < int(quote)) :
# f1.write(str(i) + "," + str(quote)+"\n")
# print(str(i) + "," + str(quote))
solution2
take ndarray And scipy.sparse.csc.csr_matrix Of each other
url
https://huwang.blog.csdn.net/article/details/84623786?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1-84623786-blog-83036442.pc_relevant_default&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1-84623786-blog-83036442.pc_relevant_default&utm_relevant_index=2
result
success
code
import scipy
from edglist_utils import load_network_data
from scipy import sparse
network_file = 'cs'
adj, features, Y = load_network_data('graphsage/input/' + network_file + '.mat')
f1 = open("graphsage/cs_create_list.txt", 'w')
my_matrix = scipy.sparse.csc_matrix(adj)
my_array = my_matrix.A
print(type(my_array))
print(len(my_array))
print(int(my_array[2][1]))
for i in range(len(my_array)):
for j in range(len(my_array)):
if int(my_array[i][j]) == 1 and i < j:
f1.write(str(i) + "," + str(j) + "\n")
边栏推荐
- Solution of intelligent management platform for suppliers in hardware and electromechanical industry: optimize supply chain management and drive enterprise performance growth
- Low CPU load and high loadavg processing method
- [pytorch] yolov5 train your own data set
- MRO industrial products enterprise procurement system: how to refine procurement collaborative management? Industrial products enterprises that want to upgrade must see!
- PMP每日一练 | 考试不迷路-7.6
- Interpretation of Dagan paper
- Use of deg2rad and rad2deg functions in MATLAB
- Sanmian ant financial successfully got the offer, and has experience in Android development agency recruitment and interview
- IC设计流程中需要使用到的文件
- 时钟轮在 RPC 中的应用
猜你喜欢
Phoenix Architecture 3 - transaction processing
C language daily practice - day 22: Zero foundation learning dynamic planning
Don't miss this underestimated movie because of controversy!
【翻译】云原生观察能力微调查。普罗米修斯引领潮流,但要了解系统的健康状况仍有障碍...
Mind map + source code + Notes + project, ByteDance + JD +360+ Netease interview question sorting
Using clip path to draw irregular graphics
Carte de réflexion + code source + notes + projet, saut d'octets + jd + 360 + tri des questions d'entrevue Netease
黑馬--Redis篇
ZABBIX proxy server and ZABBIX SNMP monitoring
Interview assault 63: how to remove duplication in MySQL?
随机推荐
Simple application of VBA script in Excel
Druid 数据库连接池 详解
Learning and Exploration - Seamless rotation map
LeetCode_ Gray code_ Medium_ 89. Gray code
DaGAN论文解读
接雨水问题解析
A popular explanation will help you get started
swagger2报错Illegal DefaultValue null for parameter type integer
[玩转Linux] [Docker] MySQL安装和配置
Teach you to learn JS prototype and prototype chain hand in hand, a tutorial that monkeys can understand
快速幂模板求逆元,逆元的作用以及例题【第20届上海大学程序设计联赛夏季赛】排列计数
【pytorch】yolov5 训练自己的数据集
short i =1; i=i+1与short i=1; i+=1的区别
MySQL information Schema Learning (i) - - General table
zabbix 代理服务器 与 zabbix-snmp 监控
【翻译】Linkerd在欧洲和北美的采用率超过了Istio,2021年增长118%。
全套教学资料,阿里快手拼多多等7家大厂Android面试真题
How to do smoke test
在解决了 2961 个用户反馈后,我做出了这样的改变...
Mysql Information Schema 學習(一)--通用錶