当前位置:网站首页>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")
边栏推荐
- Tensorflow and torch code verify whether CUDA is successfully installed
- How can my Haskell program or library find its version number- How can my Haskell program or library find its version number?
- zabbix 代理服务器 与 zabbix-snmp 监控
- LeetCode_ Gray code_ Medium_ 89. Gray code
- CPU负载很低,loadavg很高处理方法
- Actf 2022 came to a successful conclusion, and 0ops team won the second consecutive championship!!
- 三面蚂蚁金服成功拿到offer,Android开发社招面试经验
- LeetCode-1279. 红绿灯路口
- How to access localhost:8000 by mobile phone
- Looting iii[post sequence traversal and backtracking + dynamic planning]
猜你喜欢
凤凰架构3——事务处理
Fast power template for inverse element, the role of inverse element and example [the 20th summer competition of Shanghai University Programming League] permutation counting
【基础架构】Flink/Flink-CDC的部署和配置(MySQL / ES)
全套教学资料,阿里快手拼多多等7家大厂Android面试真题
A full set of teaching materials, real questions of Android interview of 7 major manufacturers including Alibaba Kwai pinduoduo
A popular explanation will help you get started
Spark foundation -scala
今日直播 | “人玑协同 未来已来”2022弘玑生态伙伴大会蓄势待发
接雨水问题解析
LeetCode_双指针_中等_61. 旋转链表
随机推荐
[translation] Digital insider. Selection process of kubecon + cloudnativecon in Europe in 2022
Is not a drawable (color or path): the vector graph downloaded externally cannot be called when it is put into mipmap, and the calling error program crashes
LeetCode_格雷编码_中等_89.格雷编码
[translation] supply chain security project in toto moved to CNCF incubator
谷粒商城--分布式高级篇P129~P339(完结)
Detailed idea and code implementation of infix expression to suffix expression
时钟轮在 RPC 中的应用
学习探索-函数防抖
手把手教你学会js的原型与原型链,猴子都能看懂的教程
Elastic search indexes are often deleted [closed] - elastic search indexes gets deleted frequently [closed]
PMP每日一练 | 考试不迷路-7.6
Mysql Information Schema 学习(二)--Innodb表
CF960G - Bandit Blues(第一类斯特林数+OGF)
Learning and Exploration - function anti shake
通俗的讲解,带你入门协程
350. 两个数组的交集 II
面试突击63:MySQL 中如何去重?
zabbix 代理服务器 与 zabbix-snmp 监控
Documents to be used in IC design process
Unbalance balance (dynamic programming, DP)