当前位置:网站首页>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")
边栏推荐
- Druid database connection pool details
- Looting iii[post sequence traversal and backtracking + dynamic planning]
- The slave i/o thread stops because master and slave have equal MySQL serv
- PMP practice once a day | don't get lost in the exam -7.6
- How to access localhost:8000 by mobile phone
- 【基础架构】Flink/Flink-CDC的部署和配置(MySQL / ES)
- Detailed idea and code implementation of infix expression to suffix expression
- 主从搭建报错:The slave I/O thread stops because master and slave have equal MySQL serv
- C # - realize serialization with Marshall class
- 反射及在运用过程中出现的IllegalAccessException异常
猜你喜欢

MySQL information schema learning (I) -- general table

腾讯Android面试必问,10年Android开发经验

MySQL information schema learning (II) -- InnoDB table
时钟轮在 RPC 中的应用

凤凰架构3——事务处理

Synchronous development of business and application: strategic suggestions for application modernization

Analysis of rainwater connection

LeetCode_双指针_中等_61. 旋转链表

Solution of intelligent management platform for suppliers in hardware and electromechanical industry: optimize supply chain management and drive enterprise performance growth

中缀表达式转后缀表达式详细思路及代码实现
随机推荐
Using clip path to draw irregular graphics
map的使用(列表的数据赋值到表单,json逗号隔开显示赋值)
ZABBIX proxy server and ZABBIX SNMP monitoring
Simple understanding of MySQL database
In depth analysis, Android interview real problem analysis is popular all over the network
Learning and Exploration - Seamless rotation map
PMP每日一练 | 考试不迷路-7.6
JDBC details
[玩转Linux] [Docker] MySQL安装和配置
Mind map + source code + Notes + project, ByteDance + JD +360+ Netease interview question sorting
学习探索-使用伪元素清除浮动元素造成的高度坍塌
数学知识——高斯消元(初等行变换解方程组)代码实现
DaGAN论文解读
Black Horse - - Redis Chapter
谷粒商城--分布式高级篇P129~P339(完结)
C language daily practice - day 22: Zero foundation learning dynamic planning
English topic assignment (25)
[translation] Digital insider. Selection process of kubecon + cloudnativecon in Europe in 2022
The list of people who passed the fifth phase of personal ability certification assessment was published
中缀表达式转后缀表达式详细思路及代码实现