当前位置:网站首页>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")
边栏推荐
- Vmware虚拟机无法打开内核设备“\\.\Global\vmx86“的解决方法
- 反射及在运用过程中出现的IllegalAccessException异常
- 关于图像的读取及处理等
- Phoenix Architecture 3 - transaction processing
- 【计算情与思】扫地僧、打字员、信息恐慌与奥本海默
- Swiftui game source code Encyclopedia of Snake game based on geometryreader and preference
- 在解决了 2961 个用户反馈后,我做出了这样的改变...
- Swagger2 reports an error illegal DefaultValue null for parameter type integer
- Hudi vs Delta vs Iceberg
- Translation D28 (with AC code POJ 26:the nearest number)
猜你喜欢
![[translation] a GPU approach to particle physics](/img/07/57036c925155cab36678c696e89440.jpg)
[translation] a GPU approach to particle physics

快速幂模板求逆元,逆元的作用以及例题【第20届上海大学程序设计联赛夏季赛】排列计数
Interview assault 63: how to remove duplication in MySQL?

The list of people who passed the fifth phase of personal ability certification assessment was published

How to type multiple spaces when editing CSDN articles
![[玩转Linux] [Docker] MySQL安装和配置](/img/04/6253ef9fdf7d2242b42b4c7fb2c607.png)
[玩转Linux] [Docker] MySQL安装和配置

Interface test tool - postman

中缀表达式转后缀表达式详细思路及代码实现

【翻译】云原生观察能力微调查。普罗米修斯引领潮流,但要了解系统的健康状况仍有障碍...

全套教学资料,阿里快手拼多多等7家大厂Android面试真题
随机推荐
Looting iii[post sequence traversal and backtracking + dynamic planning]
JDBC details
MySql必知必会学习
凤凰架构3——事务处理
Cereals Mall - Distributed Advanced p129~p339 (end)
Systematic and detailed explanation of redis operation hash type data (with source code analysis and test results)
ZABBIX proxy server and ZABBIX SNMP monitoring
【翻译】供应链安全项目in-toto移至CNCF孵化器
USB host driver - UVC swap
Solution of intelligent management platform for suppliers in hardware and electromechanical industry: optimize supply chain management and drive enterprise performance growth
PMP practice once a day | don't get lost in the exam -7.6
Learning and Exploration - function anti shake
Simple understanding of MySQL database
打家劫舍III[后序遍历与回溯+动态规划]
蓝桥杯 微生物增殖 C语言
Teach you to learn JS prototype and prototype chain hand in hand, a tutorial that monkeys can understand
Help improve the professional quality of safety talents | the first stage of personal ability certification and assessment has been successfully completed!
深入分析,Android面试真题解析火爆全网
Druid database connection pool details
黑马--Redis篇